How to live forever (if you’re a CLR object)

Just subscribe to a static event, or an event of a long-lived object (such as a singleton instance). That long lived object will keep alive all objects that subscribed to any of its events (including you).

Comments (2)

  1. Andrey Titov says:

    Huh, so easy… I wanna be a CLR object!

  2. Thomas Levesque says:

    Incidentally, that's the cause of many memory leaks… I'd love a better support for weak events (or better, weak delegates) in .NET 5 ! Ideally, it could be built into the language :

    public event EventHandler StrongEvent;

    public event EventHandler~ WeakEvent;