IIS回收等待什么? [英] What does IIS recycling wait for?
问题描述
我的意思是IIS回收了应用程序域,但尝试让待处理的请求完成而已经开始了新的请求.如果所有请求均已响应,但有一个Task正在运行,该应用程序将立即回收或与请求尚未响应时获得相同的宽限期怎么办?
What I mean is that IIS recycles app domains, but tries to let pending requests finish while already starting a new one. What if all requests have responded, but there's a Task running, will the app get recycled immediately or will it get the same grace period as when a request hasn't responded yet?
推荐答案
如果未使用 HostingEnvironment.QueueBackgroundWorkItem
向Web应用注册 Task
,则 Task
添加到队列中,那么它将尝试并等待 Task
完成.但是,等待时间不是无限的.
If you don't register the Task
with the web app using HostingEnvironment.QueueBackgroundWorkItem
, https://msdn.microsoft.com/en-us/library/dn636893(v=vs.110).aspx, then the app will only gracefully "shutdown" its own request threads. If you do add the Task
to the queue, then it will try and wait for the Task
to complete. However, the waiting period is not indefinite.
Scott Hanselman有一篇不错的文章,介绍了如何运行异步任务.
Scott Hanselman has a nice article on running async tasks.
https://www.hanselman.com/blog/HowToRunBackgroundTasksInASPNET.aspx
这篇关于IIS回收等待什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!