Possible Duplicate:
Using IDisposable to unsubscribe events
I've found myself implementing IDisposable on each class that handles events coming from objects not declared inside the class. For example:
public class Text
{
public Text(ClassWithEvents c)
{
c.Event += EventHandler;
}
}
In this situation I would declare the class Text as IDisposable and on the Dispose method I would remove the event handler to avoid having the object pinned on memory and other nasty stuff (like code executing on objects that should be dead).
I was wondering if there is a better way to do this as I don't like having too much disposable classes as they have to be "handled with care".