The scenario concerned involves the reception of a "Deactivation" event from
a session class which has reserved a bunch of resources. The subscriber -
"session manager", only has a single opportunity (in the current design) to
release the session and unsubscribe from its deactivation event. So yes, the
session manager subscriber only wants to receive the event once.

There are potentially other interested parties in the sessions deactivation
and hence my concern as regards the delegate invocation lists and the event
handler blocking (whilst it processed the unsubscription) and causing a
deadlock.

Your response was on the button as I subsequently confirmed in a small test
harness, i.e. the invocation list is immutable and the publisher continues
posting using the original list, even though the subscribers are
unsubscribing themselves when posted.

The posts also happen synchronously on the thread that invoked the delegate,
so any misbehaviour on the part of a subscriber potentially affects other
subscribers.

Thanks for the insight


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of John Elliot
Sent: 08 April, 2004 19:05
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Delegate Invocation Lists


Heh, an auto-moderator bounced me. :P

Trying again (as requested), see my comments below.

John.

>-----Original Message-----
>From: John Elliot [mailto:[EMAIL PROTECTED]
>Sent: Friday, 9 April 2004 1:30 AM
>To: 'Moderated discussion of advanced .NET topics.'
>Subject: RE: [ADVANCED-DOTNET] Delegate Invocation Lists
>
>>Would it be acceptable practice for an event handler to unsubscribe
>itself
>>whilst handling an event?
>
>Sure. Why is it that you'd want to do this? Do you only want to receive
>the event once?
>
>>My concern here lies with ...
>>
>>* corruption of the delegate invocation list whilst the event
publisher
>is
>>still busy publishing.
>
>Won't happen. Delegates are immutable. The 'event' keyword actually
does
>some funky stuff on your class, and the +=, -=, operators are
deceptive.
>Check out the 'add' and 'remove' C# keywords (which don't get proper
>syntax highlighting in C#!) and the doco for MulticastDelegate.
>
>>* blocking of the event handler until the event publisher has
completed
>>processing the list
>
>I'm not really sure what you mean by this, but the invocation list is
>dispatched synchronously on the thread that invokes the delegate.
>
>John.

===================================
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

===================================
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