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?