【问题标题】:Why does IIS get stuck on startup at PipelineRuntime.WaitForRequestsToDrain()?为什么 IIS 在 PipelineRuntime.WaitForRequestsToDrain() 启动时卡住?
【发布时间】:2014-06-20 12:11:04
【问题描述】:

当我从 Visual Studio 2013 启动 .NET 4.5 Web 应用程序时(但我不完全确定它仅限于这种情况),IIS 在启动应用程序时卡住了。如果我杀死w3wp.exe,它会自动重新启动并且应用程序运行正常。

当我将调试器附加到挂起的w3wp.exe 时,我得到下面的堆栈跟踪。只有一个名为 Worker thread 的托管线程,所有其他线程都在运行本机代码 - 因此目前没有任何自定义代码正在运行/休眠 - 只有这个。

mscorlib.dll!System.Threading.Thread.Sleep(int millisecondsTimeout)
System.Web.dll!System.Web.Hosting.PipelineRuntime.WaitForRequestsToDrain()
System.Web.dll!System.Web.HttpRuntime.Dispose()
System.Web.dll!System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(object state)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()
[Native to Managed Transition]  

这可能是什么原因?

【问题讨论】:

    标签: .net iis iis-7.5


    【解决方案1】:

    我认为你应该得到答案。我遇到了同样的问题,看起来我已经解决了。

    对我来说,这是因为我没有用.ConfigureAwait(false) 标记我的等待命令。我相信不使用它会导致主线程完成所有工作,通过切换代码段不断保持忙碌。但是这个线程因为死锁而挂在某个地方(a 等待 b,b 等待 c,c 等待 a)。

    添加.ConfigAwait(false) 会导致没有上下文的并行处理,而不是单个上下文中的线性处理。

    希望你把它修好了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-04
      • 2019-05-12
      • 1970-01-01
      • 2022-10-21
      • 1970-01-01
      • 2021-11-16
      • 2018-07-17
      • 1970-01-01
      相关资源
      最近更新 更多