What best practices for cleaning up event handler references?
Often I find myself writing code like this: if (Session != null) { Session.KillAllProcesses(); Session.AllUnitsReady -= Session_AllUnitsReady; Session.AllUnitsResultsPublished -= Session_AllUnitsResultsPublished; Session.UnitFailed -= Session_UnitFailed; Session.SomeUnitsFailed -= Session_SomeUnitsFailed; Session.UnitCheckedIn -= Session_UnitCheckedIn; UnattachListeners(); } The purpose being to clean up all event subscriptions that we have registered for on the target (Session) so that Session is free to be disposed by the GC. I had a discussion with a co-worker about classes that implement