BackgroundService BackgroundService BackgroundService Class

Definition

Base class for implementing a long running IHostedService.

public abstract class BackgroundService : IDisposable, Microsoft.Extensions.Hosting.IHostedService
type BackgroundService = class
    interface IHostedService
    interface IDisposable
Public MustInherit Class BackgroundService
Implements IDisposable, IHostedService
Inheritance
BackgroundServiceBackgroundServiceBackgroundService
Implements

Constructors

BackgroundService() BackgroundService() BackgroundService()

Methods

Dispose() Dispose() Dispose()
ExecuteAsync(CancellationToken) ExecuteAsync(CancellationToken) 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.

StartAsync(CancellationToken) StartAsync(CancellationToken) StartAsync(CancellationToken)

Triggered when the application host is ready to start the service.

StopAsync(CancellationToken) StopAsync(CancellationToken) StopAsync(CancellationToken)

Triggered when the application host is performing a graceful shutdown.

Applies to