gpt4 book ai didi

iis - IIS 回收时是否调用了 IHostedService.StopAsync()?

转载 作者:行者123 更新时间:2023-12-05 05:10:29 38 4
gpt4 key购买 nike

这个问题是关于在 IIS 上运行的 ASP.NET Core 2.2 应用程序,特别是在注册 IHostedService 的实例时。与 DI 容器。

我阅读的每篇文章 IHostedService.StopAsync()只是谈论当主机“关闭”时调用 StopAsync(),但我想知道 IIS 回收时会发生什么。

我的问题:

<强>1。 IIS回收时是否调用了StopAsync()

<强>2。无论使用 InProcess 托管还是 OutOfProcess 托管,答案都一样吗?(ASP.NET Core 从 2.2 版开始支持 InProcess )

最佳答案

  1. 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 - IIS 回收时是否调用了 IHostedService.StopAsync()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56601535/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com