我爱Aspx >> Asp.Net >> [Remoting]当client不复存在而RemoteObject并不知道时的处理办法The basic idea is that we
1) gain Access to the multicast delegate instance that contains our event subscribers in its invocation list
2) loop through this invocation list and try to manually call invoke on each item
3) catch any exceptions from dead clients
4) remove dead client subscriptions from the invocation list
5) continue manually calling invoke on all the remaining items in invocation list.
那么就是轮循解决了:(客户端靠不住,估计只能依靠服务器端主动了):
public delegate void DelegateUsed( parameter list );
public event DelegateUsed ExampleEvent;
public void RaiseExampleEvent( )
{
Delegate[] targets = DelegateUsed.GetInvocationList();
foreach( DelegateUsed client in targets )
{
try
{
// Callback to client...
client( parameter list of delegate );
}
catch
{
// Failed to callback to client, remove reGIStered delegate.
RemoteFavoriteChanged -= client;
}
}
}
这样剔除那些不存在了的client。
编写者:郑昀@ultrapower
上一篇: remoting使用手记
下一篇: 在Remoting Server上取得Remoting Client的IP地址
Ҷƪл˵?
(原创)一步一步学Remoting之三:..[05-15]
(原创)一步一步学Remoting之一:..[05-15]
(原创)一步一步学Remoting之四:..[05-15]
(原创)一步一步学Remoting之二:..[05-15]
(原创)一步一步学Remoting之五:..[05-15]
Remoting的事件机制(带具体例子..[05-15]
Remoting之异步操作模式[05-15]
RemotingIIS承载方式[05-15]
Remoting的承载方式是这样的[05-15]
Web服务体系结构[05-15]