次の方法で共有


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

  • Anonymous
    May 24, 2010
    Huh, so easy... I wanna be a CLR object!

  • Anonymous
    May 24, 2010
    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;