Once I add an event handler to a Timer, how do I remove it? For my purposes
it is good enough to remove ALL event handlers as I'll only have one
associated with the Timer at any time.
Basically, I'm looking for something like:
timer->Tick = NULL ;
Maybe that will work (haven't tried it)? I'm guessing if it does the
EventHandler[s] associated with it, being garbage collected, should go out
of scope and be destroyed. But that's only if the above method makes
sense...
Thanks in advance for any responses! : )
Alex Thaman - 07 Oct 2005 16:36 GMT
I think you want
timer->Tick -= new YourEventDelegate(instance, yourEventHandler);
Check out http://msdn2.microsoft.com/en-us/library/4b612y2s for an example of how this is done. This is a reference for the new C++/CLI syntax. If you are using __event, check out http://msdn2.microsoft.com/en-us/library/cb1dzt8t.
-Alex
-----Original Message-----
From: Peter Oliphant
Posted At: Wednesday, October 05, 2005 4:13 PM
Posted To: microsoft.public.dotnet.languages.vc
Conversation: Removing EventHandle[s] from a Timer
Subject: Removing EventHandle[s] from a Timer
Once I add an event handler to a Timer, how do I remove it? For my purposes
it is good enough to remove ALL event handlers as I'll only have one
associated with the Timer at any time.
Basically, I'm looking for something like:
timer->Tick = NULL ;
Maybe that will work (haven't tried it)? I'm guessing if it does the
EventHandler[s] associated with it, being garbage collected, should go out
of scope and be destroyed. But that's only if the above method makes
sense...
Thanks in advance for any responses! : )