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

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

  • Comments 2

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).

  • Huh, so easy... I wanna be a CLR object!

  • 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;

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post