Weak events in .NET?

后端 未结 9 1980
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 16:37

If object A listens to an event from object B, object B will keep object A alive. Is there a standard implementation of weak events that would prevent this? I know WPF has s

9条回答
  •  一生所求
    2020-12-04 17:30

    Using the recommended Dispose() pattern, where you consider events a managed resource to clean up, should handle this. Object A should unregister itself as a listener of events from object B when it's disposed...

提交回复
热议问题