IHostedLifecycleService 接口

定义

定义在 和 StopAsync(CancellationToken)之前或之后StartAsync(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)

在 之后 StartAsync(CancellationToken)触发。

StartingAsync(CancellationToken)

在 之前 StartAsync(CancellationToken)触发。

StopAsync(CancellationToken)

当应用程序主机执行正常关闭时触发。

(继承自 IHostedService)
StoppedAsync(CancellationToken)

在 之后 StopAsync(CancellationToken)触发。

StoppingAsync(CancellationToken)

在 之前 StopAsync(CancellationToken)触发。

扩展方法

StartAndStopAsync(IHostedService, CancellationToken)

启动并立即停止服务。

适用于