[英]“Thread was being aborted ” on WCF service
我們正在嘗試開發WCF服務來執行長時間運行的任務。 如果任務已成功排隊,則實現長時間運行的任務的方法將產生一個新任務,並立即返回到客戶端(在本例中為.aspx頁)。 該服務在自己的應用程序池上運行,沒有回收並且只有一個InstanceContextMode。
WCF服務
[OperationContract]
public bool testThreadAbortException()
{
Task.Factory.StartNew
(
() =>
{
try
{
//long operation
int i = 0;
while (i < 250)
{
int j = 0;
while (j < 2000000) j++;
i++;
}
ThreadState state = Thread.CurrentThread.ThreadState;
string dummy = "finished ";
}
catch(Exception exception)
{
ThreadState state = Thread.CurrentThread.ThreadState;
string msg = exception.Message;
Exception inner = exception.InnerException;
}
}
);
return true;
}
客戶
protected void btnRun_Click(object sender, EventArgs e)
{
_default.IISHOST_ETLSchedulerServiceReference.ETLSchedulerServiceClient client = new _default.IISHOST_ETLSchedulerServiceReference.ETLSchedulerServiceClient();
bool ret = client.testThreadAbortException();
}
現在的問題是,在執行testThreadAbortException方法時,我捕獲到線程被異常中止(這總是在客戶端退出事件處理程序方法之后發生)。 奇怪的是,此異常僅在第一次時拋出(即,如果我再次按下運行按鈕,代碼將正常執行)。 我必須重新啟動本地IIS才能再次復制該錯誤。
看起來它的Mcafee防病毒程序畢竟正在訪問hash.web文件。 通過過程監控器確認。 去圖.....有關更多信息,請查看此帖子。 問題類似於我的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.