לקריאה באנגלית

שתף באמצעות


IHostedLifecycleService Interface

Definition

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

C#‎
public interface IHostedLifecycleService : Microsoft.Extensions.Hosting.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

מוצר גירסאות
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)