Using “async” (even if it should complete) as part of a MVC route deadlocks the route; how can this be avoided?

前端 未结 3 438
悲哀的现实
悲哀的现实 2020-12-24 08:45

Consider the following (based on the default MVC template), which is a simplified version of some \"stuff\" that happens in the background - it completes fine, and shows the

3条回答
  •  爱一瞬间的悲伤
    2020-12-24 09:38

    It's to do with the way the synchronization context is implemented in ASP.NET (Pre .NET 4.5). There's tons of questions about this behavior:

    Task.WaitAll hanging with multiple awaitable tasks in ASP.NET

    Asp.net SynchronizationContext locks HttpApplication for async continuations?

    In ASP.NET 4.5, there's a new implementation of the sync context that's described in this article.

    http://blogs.msdn.com/b/webdev/archive/2012/11/19/all-about-httpruntime-targetframework.aspx

提交回复
热议问题