Hi Greg,
It depends of what do you mean by closing the form. If you remove all
references to the form object you shouldn't bother for removing the events'
subscribers. As long as events are not *root* references they will not keep
the subscribers alive. If you, however, dispose the form and keep references
to the form Dispose method will destroy underlaying native window, but the
form object itself will be considered as alive in the managed heap. In the
latter case all subscribers will be considered as referenced by the GC.
HTH
B\rgds
100
"Greg Patrick" <pr*****@private.com> wrote in message
news:B7neb.5191$f7.343045@localhost...
Let's say I have a Form and I create a delegate (MyDelegate) and an event
(SomethingHappened) for that form.
Now other classes add their delegate to the event, e.g.
theForm.SomethingHappened += new MyDelegate(this.myMethod);
When I Close the form, how do I properly dispose of the delegates of the
event?
Does each subcriber need to do a -= ?
Or can I just put this.SomethingHappened = null in the Dispose(bool) of
the Form?
I want to make sure the subscribers don't still have a reference that
would prevent garbage collection of the form...
Greg Patrick