我在.NET 4.0中創建任務時遇到了一個奇怪的例外。在.net 4.0上處理任務異常
我越來越與全球Updomain未處理的異常處理程序窗口服務異常,所以我沒有確切的堆棧:A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property.
我認爲它發生在下面的代碼段:
for (int i = 0; i < _workers.Length; ++i)
{
int j = i; // copy
Task t1 = Task.Factory.StartNew(() =>
{
try
{
if (!_workers[j].Join(4000))
LogWriter.Trace("Failed to join thread", "ThreadFailureOnDispose");
}
catch (Exception ex)
{
OnLogged(ex.Message + ex.StackTrace);
}
});
}
有人有想法嗎?它是否具有聚合異常功能?
有關於此的一些相當不錯的信息:http://social.msdn.microsoft.com/Forums/en-US/rx/thread/ee5dba5d-eea9-4d85-8f58-c2e1c71ef33a – 2010-10-17 15:12:43
第一次修復您的UnhandledException事件處理程序。 _workers任務也是如此嗎? – 2010-10-17 15:15:14
沒有。 _工人是線程。你是什麼意思解決我的UnhandledException事件處理程序?從某種原因Windows服務停止,儘管執行被捕獲並記錄在AppDomain.CurrentDomain.UnhandledException。 – user437631 2010-10-17 16:23:09