Weak Events in C# – CodeProject


Weak Events in C# – CodeProject

When using normal C# events, registering an event handler creates a strong reference from the event source to the listening object.
If the source object has a longer lifetime than the listener, and the listener doesn’t need the events anymore when there are no other references to it, using normal .NET events causes a memory leak: the source object holds listener objects in memory that should be garbage collected.
There are lots of different approaches to this problem. This article will explain some of them and discuss their advantages and disadvantages.

Related Posts