Events unsubscribing and resource leaks?



Hey guys

When you hook an event (c# 2.0 syntax): myEvent += MyMethodToFire;

You need to also unsubscribe it to avoid a resource leak so that the object
it is in gets garbage collected like so : myEvent -= MyMethodToFire;

That's all fine, but when you use visual studio to create events for objects
it never creates an unsubscribing reference, so is it puting in resource
leaks? Or is this being cleared somewhere that i am not seeing?

Also what is the best way to clean up a singleton class?


.



Relevant Pages

  • Re: Events unsubscribing and resource leaks?
    ... You need to also unsubscribe it to avoid a resource leak so that the ... reciever, this also wouldn't prevent the instance from being collected. ... recieve the event while the sender remains to exist. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Dual Core processor ?
    ... to avoid (infrequent) random filesystem errors. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Compaq 1850R
    ... I hope to install this weekend and hope to avoid any major issues. ... Tanks... ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: xrdb questions
    ... Andrew Cady writes: ... That's why I told you how to avoid it! ... up all the time and is rarely rebooted, emacs must be closed and ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Difference between Lenny/testing?
    ... that had been kept back during the freeze. ... To avoid the chaos that would ensue (for how long? ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)

Loading