BackgroundService.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.

protected:
 abstract System::Threading::Tasks::Task ^ ExecuteAsync(System::Threading::CancellationToken stoppingToken);
protected abstract System.Threading.Tasks.Task ExecuteAsync (System.Threading.CancellationToken stoppingToken);
abstract member ExecuteAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
Protected MustOverride Function ExecuteAsync (stoppingToken As CancellationToken) As Task

參數

stoppingToken
CancellationToken

當呼叫 StopAsync(CancellationToken) 時觸發。Triggered when StopAsync(CancellationToken) is called.

傳回

Task

表示長時間執行作業的 TaskA Task that represents the long running operations.

適用於