Hi David
Thanks for the response. I have got few more questions for you:
How to take care of the memory leaks in such cases?
Are there in safeguards in .Net against it, except good programming
practices?
How about using WeakReferences to link the two Event objects?
Regards
Rahul
> > Hi all
> >
[quoted text clipped - 14 lines]
>
> David
David Browne - 25 Jul 2003 17:35 GMT
> Hi David
>
[quoted text clipped - 4 lines]
> practices?
> How about using WeakReferences to link the two Event objects?
Well that's not how events are implemented, but they could have been.
If you used interfaces instead of events, you could use weak references to
notitify the object without keeping it from being collected.
But only good programming prevents this. You might make your objects
Disposable, and remove the event handler in the Dispose method.
David
Niall - 28 Jul 2003 01:38 GMT
Weak references could have worked in this situation. Bear in mind that it's
only really an issue when your object is hooking onto an event in another
object which has a significantly longer life span. But it can be a really
nasty situation, especially if it's not you hooking up the event, but
something in the framework, and your object ends up being referenced through
a static hashtable or similar.
Niall
> Hi David
>
[quoted text clipped - 30 lines]
> >
> > David