BackgroundService 類別

定義

此基底類別可實作長時間執行的 IHostedServiceBase class for implementing a long running IHostedService.

public ref class BackgroundService abstract : IDisposable, Microsoft::Extensions::Hosting::IHostedService
public abstract class BackgroundService : IDisposable, Microsoft.Extensions.Hosting.IHostedService
type BackgroundService = class
    interface IHostedService
    interface IDisposable
Public MustInherit Class BackgroundService
Implements IDisposable, IHostedService
繼承
BackgroundService
實作

建構函式

BackgroundService()

方法

Dispose()
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
ExecuteAsync(CancellationToken)

IHostedService 啟動時,會呼叫此方法。This method is called when the IHostedService starts. 此實作應傳回工作,以表示所執行長時間執行作業的存留期。The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
StartAsync(CancellationToken)

當應用程式主機準備好啟動服務時觸發。Triggered when the application host is ready to start the service.

StopAsync(CancellationToken)

當應用程式主機執行順利關機時觸發。Triggered when the application host is performing a graceful shutdown.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於