views:

143

answers:

1

Learning from INGO RAMMER's "Advanced .NET Remoting", I tried to use the following codes for firing events to clients:

foreach (Delegate del in MessageArrived.GetInvocationList()) 
{
try 
{
mah = (MessageArrivedHandler) del;
mah(msg);
} 
catch (Exception e) 
{
Console.WriteLine("Exception occured, will remove Delegate");
MessageArrived -= mah;
}
}

When I simulated a network problem in client side, the client's delegate was removed by -= as expected, and the MessageArrived became null.

But as the network was restored, the client will try to connect, get remote object and re-register event as it does same for startup, it seems the re-registeration was successful as the MessageArrived was not null.

The problem is I still got the exception will invoke the delegate which was then removed. As I understand, this shall not raise expcetion coz. the client is online again and re-connect() and connect() method shares the same codes...

Can anybody help me?

A: 

Check whether the unregistering of events is happening properly or not. When the client is disconnected it is preferable to unregister the events gracefully.

srikanthv