在下面的代码(wcf 服务器)中,如果客户端断开连接,我希望代码继续处理。现在它跳转到 catch 语句并停止处理。回调的目的最终将更新客户端的请求进度,但客户端可以在任何阶段断开连接,并且我希望继续处理。
public void ChatToServer(string texttoServer) // send some text to the server
{
Logging.Write_To_Log_File("Entry", MethodBase.GetCurrentMethod().Name, "", "", "", 1);
try
{
Thread.Sleep(5000);
IMyContractCallBack callback = OperationContext.Current.GetCallbackChannel<IMyContractCallBack>();
callback.callbacktoServer("Progress is 20% complete");
// Some extremely important processing
....
callback.callbacktoServer("Progress is 40% complete");
// Some extremely important processing
....
callback.callbacktoServer("Progress is 60% complete");
// Some extremely important processing
....
callback.callbacktoServer("Progress is 80% complete");
// Some extremely important processing
....
callback.callbacktoServer("Progress is 100% complete");
}
catch (Exception ex)
{
}
}