IIS回收时调用IHostedService.StopAsync()吗?
Is IHostedService.StopAsync() called when IIS recycles?
此问题与 IIS 上的 ASP.NET Core 2.2 应用程序 运行 有关,特别是在向 DI 容器注册 IHostedService 实例时。
我读到的每一篇关于IHostedService.StopAsync()的文章都只是在讲当主机"shuts down"时调用StopAsync()
,但我想知道IIS回收时会发生什么。
我的问题:
1. IIS回收时是否调用了StopAsync()
?
2。无论使用 InProcess
托管还是 OutOfProcess
托管,答案都一样吗?(ASP.NET 核心支持 InProcess
版本 2.2)
- Is
StopAsync()
called when the IIS recycles?
是
引用Implement background tasks in microservices with IHostedService and the BackgroundService class
Deployment considerations and takeaways
It is important to note that the way you deploy your ASP.NET Core
WebHost or .NET Core Host might impact the final solution. For
instance, if you deploy your WebHost on IIS or a regular Azure App
Service, your host can be shut down because of app pool recycles.
.....
注意:强调我的
这将停止任何 IHostedService
、
此问题与 IIS 上的 ASP.NET Core 2.2 应用程序 运行 有关,特别是在向 DI 容器注册 IHostedService 实例时。
我读到的每一篇关于IHostedService.StopAsync()的文章都只是在讲当主机"shuts down"时调用StopAsync()
,但我想知道IIS回收时会发生什么。
我的问题:
1. IIS回收时是否调用了StopAsync()
?
2。无论使用 InProcess
托管还是 OutOfProcess
托管,答案都一样吗?(ASP.NET 核心支持 InProcess
版本 2.2)
- Is
StopAsync()
called when the IIS recycles?
是
引用Implement background tasks in microservices with IHostedService and the BackgroundService class
Deployment considerations and takeaways
It is important to note that the way you deploy your ASP.NET Core WebHost or .NET Core Host might impact the final solution. For instance, if you deploy your WebHost on IIS or a regular Azure App Service, your host can be shut down because of app pool recycles.
.....
注意:强调我的
这将停止任何 IHostedService
、