Partager via


IHostedLifecycleService Interface

Definition

Defines methods that are run before or after StartAsync(CancellationToken) and StopAsync(CancellationToken).

public interface class IHostedLifecycleService : Microsoft::Extensions::Hosting::IHostedService
public interface IHostedLifecycleService : Microsoft.Extensions.Hosting.IHostedService
type IHostedLifecycleService = interface
    interface IHostedService
Public Interface IHostedLifecycleService
Implements IHostedService
Implements

Methods

StartAsync(CancellationToken)

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

(Inherited from IHostedService)
StartedAsync(CancellationToken)

Triggered after StartAsync(CancellationToken).

StartingAsync(CancellationToken)

Triggered before StartAsync(CancellationToken).

StopAsync(CancellationToken)

Triggered when the application host is performing a graceful shutdown.

(Inherited from IHostedService)
StoppedAsync(CancellationToken)

Triggered after StopAsync(CancellationToken).

StoppingAsync(CancellationToken)

Triggered before StopAsync(CancellationToken).

Extension Methods

StartAndStopAsync(IHostedService, CancellationToken)

Starts and immediately stops the service.

Applies to