IHostedLifecycleService 接口
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义在 StartAsync(CancellationToken) 和 StopAsync(CancellationToken)之前或之后运行的方法。
public interface class IHostedLifecycleService : Microsoft::Extensions::Hosting::IHostedService
public interface IHostedLifecycleService : Microsoft.Extensions.Hosting.IHostedService
type IHostedLifecycleService = interface
interface IHostedService
Public Interface IHostedLifecycleService
Implements IHostedService
- 实现
方法
| StartAsync(CancellationToken) |
当应用程序主机准备好启动服务时触发。 (继承自 IHostedService) |
| StartedAsync(CancellationToken) | |
| StartingAsync(CancellationToken) | |
| StopAsync(CancellationToken) |
在应用程序主机执行正常关闭时触发。 (继承自 IHostedService) |
| StoppedAsync(CancellationToken) | |
| StoppingAsync(CancellationToken) |
在 StopAsync(CancellationToken)之前触发。 |
扩展方法
| StartAndStopAsync(IHostedService, CancellationToken) |
启动并立即停止服务。 |