未捕获异常的 Task.Factory.StartNew 会杀死 w3wp?
我刚刚将我网站的一些代码从使用QueueUserWorkItem
转换为Task.Factory.StartNew
我有一些错误的代码抛出异常并最终关闭了w3wp。在 Windows Server 2008 R2、x64 上运行 IIS 7.5
Task.Factory.StartNew(() =>
{
MethodThatThrowsException();
}
应用程序:w3wp.exe 框架版本:v4.0.30319 描述:由于未处理的异常,进程被终止。 异常信息:System.AggregateException 堆: 在 System.Threading.Tasks.TaskExceptionHolder.Finalize()
异常:System.AggregateException
消息:通过等待任务或访问其 Exception 属性均未观察到任务的异常。结果,未观察到的异常被终结器线程重新抛出。
StackTrace:位于 System.Threading.Tasks.TaskExceptionHolder.Finalize()
内部异常:System.Data.SqlClient.SqlException
我本以为异常会生成事件日志,并且不已经杀死了w3wp。这是一个错误的假设吗?
I just transitioned some of my website's code from using QueueUserWorkItem
to Task.Factory.StartNew
I have some bad code that threw an Exception and it ultimately shut down w3wp. Running IIS 7.5 on Windows Server 2008 R2, x64
Task.Factory.StartNew(() =>
{
MethodThatThrowsException();
}
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AggregateException
Stack:
at System.Threading.Tasks.TaskExceptionHolder.Finalize()Exception: System.AggregateException
Message: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
StackTrace: at System.Threading.Tasks.TaskExceptionHolder.Finalize()
InnerException: System.Data.SqlClient.SqlException
I would have assumed an exception would have generated an event log and NOT have killed w3wp. Is this a wrong assumption?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未处理的异常会导致 IIS 工作进程崩溃。这是设计使然。 http://support.microsoft.com/kb/911816
因此,您应该正确处理异常。
Unhandled exceptions crash IIS worker process. This is by design. http://support.microsoft.com/kb/911816
Therefore, you should properly handle exceptions.