Class BackgroundService
Base class for implementing a long running IHostedService.
public abstract class BackgroundService : IHostedService, IDisposable
- Inheritance
-
BackgroundService
- Implements
- Inherited Members
Methods
Dispose()
public virtual void Dispose()
ExecuteAsync(CancellationToken)
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 Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingToken
CancellationTokenTriggered when StopAsync(CancellationToken) is called.
Returns
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
public virtual Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenIndicates that the start process has been aborted.
Returns
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public virtual Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenIndicates that the shutdown process should no longer be graceful.