語言

ApplicationLifetime 類別

定義

允許消費者在優雅關機期間進行清理。

public ref class ApplicationLifetime : Microsoft::Extensions::Hosting::IApplicationLifetime, Microsoft::Extensions::Hosting::IHostApplicationLifetime
public class ApplicationLifetime : Microsoft.Extensions.Hosting.IApplicationLifetime, Microsoft.Extensions.Hosting.IHostApplicationLifetime
type ApplicationLifetime = class
    interface IApplicationLifetime
    interface IHostApplicationLifetime
Public Class ApplicationLifetime
Implements IApplicationLifetime, IHostApplicationLifetime
繼承
ApplicationLifetime
實作

備註

此 API 支援 .NET 基礎架構,並非直接從你的程式碼中使用。

建構函式

名稱 Description
ApplicationLifetime(ILogger<ApplicationLifetime>)

使用指定的記錄器初始化實 ApplicationLifetime 例。

屬性

名稱 Description
ApplicationStarted

會拿到取消代幣。 當應用程式主機完全啟動並準備等待優雅關機時觸發。

ApplicationStopped

會拿到取消代幣。 當應用程式主機執行優雅關機時會觸發。 所有申請此時應該都已完成。 關閉會被封鎖,直到事件結束。

ApplicationStopping

會拿到取消代幣。 當應用程式主機執行優雅關機時會觸發。 請求可能還在飛行中。 關閉會被封鎖,直到事件結束。

方法

名稱 Description
NotifyStarted()

ApplicationStarted觸發並封鎖直到完成。

NotifyStopped()

ApplicationStopped觸發並封鎖直到完成。

StopApplication()

ApplicationStopping觸發並封鎖直到完成。

適用於