BackgroundService.ExecuteAsync(CancellationToken) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Triggered when StopAsync(CancellationToken) is called.
A Task that represents the long running operations.
The cancellation token was canceled. This exception is stored into the returned task.
See Worker Services in .NET for implementation guidelines.
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: