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)

啟動並立即停止服務。

適用於