【发布时间】:2018-11-15 20:05:10
【问题描述】:
我在看BackgroundService 来自Implement background tasks in microservices with IHostedService and the BackgroundService class
我要转换为从BackgroundService 继承的类实现了IDisposable。
由于BackgroundService 没有公开Dispose(bool disposing),因此我无法在我的服务的Dispose(bool disposing) 中调用base.Dispose(disposing);。
从BackgroundService 继承的类是否会在StopAsync 中进行清理(或者在ExecuteAsync 中有清理代码)?
【问题讨论】:
-
它对
StopAsync表示:“当应用程序主机执行正常关闭时触发。”。我猜你会在那里打扫卫生。 -
你也可以直接实现
IHostedService?
标签: c# azure idisposable