Ok. What makes something qualify for Garbage Collection? I ask because I'm worried the events I'm hooking up might be keeping the objects from being disposed of.
You tell the program you're interested in an event by using the += like so:
this.OnClick += new EventHandler(this_Clicked);
Assume "this" is a control that is part of a form's Controls collection. When I clear the form's Controls collection is this control disposed of? I believe it is waiting for garbage collection, but do I have to "unhook" the event (using -=) before the control qualifies for garbage collection, or is the CLR smart enough to figure out I won't ever be using that control again? I'm worried the control (now removed from the controls collection) is sitting there isolated in memory watching for an event that will never happen.
You tell the program you're interested in an event by using the += like so:
this.OnClick += new EventHandler(this_Clicked);
Assume "this" is a control that is part of a form's Controls collection. When I clear the form's Controls collection is this control disposed of? I believe it is waiting for garbage collection, but do I have to "unhook" the event (using -=) before the control qualifies for garbage collection, or is the CLR smart enough to figure out I won't ever be using that control again? I'm worried the control (now removed from the controls collection) is sitting there isolated in memory watching for an event that will never happen.