Groups | Blog | Home
all groups > dotnet remoting > february 2004 >

dotnet remoting : Event deactivation: synchronous or asynchronous



gs_sarge NO[at]SPAM yahoo.com
2/20/2004 1:39:55 AM
Hi:

I was wondering what the behavior is when a delegate is unregistered
from an event.


For example:

Say I've registered my delegate on a server and then the server
crashes at some point. I don't know this, so I make a call like this
when I'm logging off

server.serverDelegateEvent -= new ServerDelegate(myServerDelegate);

will this line wait for a reply? or is it aynchronous? If it waits
for a reply, is there a way to make it an asynchronous one way call?
I can't picture in my head of any way to make this call asynchronous
if it isn't already. But then again, I'm no C# guru.

Any advice and/or help is appreciated.

Sunny
2/20/2004 10:40:20 AM
Hi Steve,
please, read inline:


In article <4035644e.70510108@news.microsoft.com>, gs_sarge@yahoo.com
says...
[quoted text, click to view]
Yes, subscribtion/unsubscribtion from the event is like a normal method
invocation, so the client will wait for the call to return.

[quoted text, click to view]

the quick way is to put the subscription/unsubscribtion from the event
in separate methods at the client. Then you can create delegates to
these methods and call them asynchronously. The following code is not
tested (I just type it in the reader, so be careful for typos):

private delegate void ManageEventDelegate();

private void AttachHandler()
{
server.serverDelegateEvent += new ServerDelegate(myServerDelegate);
}

private void DettachHandler()
{
server.serverDelegateEvent -= new ServerDelegate(myServerDelegate);
}

//and in your code you make something like:

ManageEventDelegate dd = new ManageEventDelegate(this.DettachHandler);
dd.BeginInvoke(null, null);


Please, note again, I have never used this, as I do not think that I
should not care about if event unsubscription will fail.
But is should work if you realy need this.

Hope that helps
gs_sarge NO[at]SPAM yahoo.com
2/21/2004 4:13:37 AM
Thank you for the info. That's good advice

steve

On Fri, 20 Feb 2004 10:40:20 -0600, Sunny
[quoted text, click to view]
AddThis Social Bookmark Button