語言

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
實作

方法

名稱 Description
StartAsync(CancellationToken)

當應用程式主機準備好啟動服務時會被觸發。

(繼承來源 IHostedService)
StartedAsync(CancellationToken)

觸發於 StartAsync(CancellationToken)。

StartingAsync(CancellationToken)

之前 StartAsync(CancellationToken)被觸發過。

StopAsync(CancellationToken)

當應用程式主機執行優雅關機時會觸發。

(繼承來源 IHostedService)
StoppedAsync(CancellationToken)

觸發於 StopAsync(CancellationToken)。

StoppingAsync(CancellationToken)

之前 StopAsync(CancellationToken)被觸發過。

擴充方法

名稱 Description
StartAndStopAsync(IHostedService, CancellationToken)

開始服務後立刻停止。

適用於