0
,如果客戶端斷開連接,我希望代碼繼續處理。現在它跳轉到catch語句並停止處理。回調的目的最終將更新客戶端的請求進度,但客戶端可以在任何階段斷開連接,並且我想要繼續處理。在下面的代碼(wcf服務器)中回撥繼續
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)
{
}
}
你正在C#中進行java編程,你應該使用委託,而不是接口。 – antonijn 2013-03-21 18:07:11