Difference between Task.Run and QueueBackgroundWorkItem in Asp.Net

后端 未结 3 1749
你的背包
你的背包 2020-12-13 17:32

What exactly is the difference using

Task.Run(() => { 
     LongRunningMethod();
});

or

HostingEnvironment.QueueBack         


        
3条回答
  •  Happy的楠姐
    2020-12-13 18:03

    The AppDomain shutdown can only be delayed 90 seconds (It’s actually the minimum of HttpRuntimeSection.ShutdownTimeout and processModel shutdownTimeLimit). If you have so many items queued that they can’t be completed in 90 seconds, the ASP.NET runtime will unload the AppDomain without waiting for the work items to finish.

    https://blogs.msdn.microsoft.com/webdev/2014/06/04/queuebackgroundworkitem-to-reliably-schedule-and-run-background-processes-in-asp-net/

提交回复
热议问题