客户端注册服务端事件
foreach (Delegate del in BroadCastEvent.GetInvocationList())  
{  
try  
{  
tempEvent = (BroadCastEventHandler)del;  
tempEvent(info);  
}  
catch  
{   
MessageBox.Show( "事件订阅者 " + index.ToString() + "发生错误,系统将取消事件订阅! ");  
BroadCastEvent -= tempEvent;  
}  
当客户端断网后,程序要45秒左右才能引发异常然后BroadCastEvent -= tempEvent; 能否缩短这个时间,最好在配置文件中更改,或者有其他办法解决
补充:异步方式考虑过,但是我的调用量非常大 因为不能马上返回可能导致线程池满,造成堵塞

解决方案 »

  1.   

    可能是你整体设计造成的困难。比如用Remoting去做大型的聊天程序,当然不能有好的结局。
      

  2.   

    webservice不支持远程事件,无法做到服务端主动通知
    udp、tcp涉及防火墙问题
    remoting的http信道是个不错的选择,唯一的遗憾就是客户端非正常断开后,服务端要在45秒后才引发异常
    如果我采用服务端轮询客户端来判断,那么BroadCastEvent -= tempEvent; 就成了鸡肋
    我现在只是想缩短处罚事件的超时时间
      

  3.   

    问题基本解决了,把我的方法公布出来  希望以后遇到同样问题的哥们有个参考
    第一步:  <channel port="8081" ref="http" timeout="2000">
    设置超时时间,这个时间我测试过是有效果的。
    客户端服务端都要设置,具体根据当地的网络情况第二步:在触发事件时采用委托
     private void OnSendConflictEvent(RemSendConflictEventArgs e)
            {
                if (RemSendConflictEvent != null)
                {
                    RemSendConflictEventHandler tempEvent = null;
                    foreach (Delegate del in this.RemSendConflictEvent.GetInvocationList())
                    {
                        tempEvent = (RemSendConflictEventHandler)del;
                        MyDelegateOnSendConflictEvent md = new   MyDelegateOnSendConflictEvent(Ia_OnSendConflictEvent);
                        IAsyncResult Iar = md.BeginInvoke(tempEvent, e, null, null);
                    }
                }
            }
    没有直接tempEvent .BeginInvoke是因为要在服务端捕获异常
    这样基本大的通信量,是可以满足了
    当线程池满时,会在设置的时间内超时 不会出现阻塞,不会印象其他客户端的事件触发