语言

IHostedLifecycleService 接口

定义

定义之前或之后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)

触发后 StartAsync(CancellationToken)。

StartingAsync(CancellationToken)

在 .. 之前 StartAsync(CancellationToken)触发。

StopAsync(CancellationToken)

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

(继承自 IHostedService)
StoppedAsync(CancellationToken)

触发后 StopAsync(CancellationToken)。

StoppingAsync(CancellationToken)

在 .. 之前 StopAsync(CancellationToken)触发。

扩展方法

名称 说明
StartAndStopAsync(IHostedService, CancellationToken)

启动并立即停止服务。

适用于