Unregistering from event handlers

  • Thread starter Thread starter Dave Townsend
  • Start date Start date
D

Dave Townsend

Is there any differences between these two ways of registering for then
deregistering from an event handler?

Situation 1:

event+=new EventHandler(Handler);
/* ... */
event-=new EventHandler(Handler);

Situation 2:

EventHandler handle = new EventHandler(Handler);
event+=handle;
/* ... */
event-=handle;


Dave
 
Dave,
Is there any differences between these two ways of registering for then
deregistering from an event handler?

Situation 2 allocates one less object. Other than that, no.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top