Hi Steve,
please, read inline:
In article <4035644e.70510108@news.microsoft.com>, gs_sarge@yahoo.com
says...
[quoted text, click to view] > 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?
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] > 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.
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