Well, it depends.
If you have implemented the event the easy way, by using a standard
MulticastDelegate, i.e. public event BlahBlahEventHandler BlahBlah it's not
a good idea (I'm not sure, but that could really corrupt the single linked
list MS gods use there, and at least, you cannot guarantee whether it will
work in the next framework version), otherwise, if you are the one, building
and using the delegate invocation list, you could do that. Still, I don't
consider this a good practice. Why do you want to do this? To save the
subscriber from remembering that it should unsubscribe? You'd better have a
method, taking a delegate, which is invoked when the "event" happens.

Cheers,
Stoyan

-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ross Diesel
Sent: Tuesday, April 06, 2004 12:45
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Delegate Invocation Lists

==========================================================================

Would it be acceptable practice for an event handler to unsubscribe itself
whilst handling an event?

My concern here lies with ...

* corruption of the delegate invocation list whilst the event publisher is
still busy publishing.

* blocking of the event handler until the event publisher has completed
processing the list

Thanks

===================================
This list is hosted by DevelopMentorR  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to