Afficher en anglais

Partage via


IHostedLifecycleService Interface

Définition

Définit les méthodes qui sont exécutées avant ou après StartAsync(CancellationToken) et StopAsync(CancellationToken).

C#
public interface IHostedLifecycleService : Microsoft.Extensions.Hosting.IHostedService
Implémente

Méthodes

StartAsync(CancellationToken)

Déclenché lorsque l’hôte de l’application est prêt à démarrer le service.

(Hérité de IHostedService)
StartedAsync(CancellationToken)

Déclenché après StartAsync(CancellationToken).

StartingAsync(CancellationToken)

Déclenché avant StartAsync(CancellationToken).

StopAsync(CancellationToken)

Déclenché lorsque l’hôte de l’application effectue un arrêt approprié.

(Hérité de IHostedService)
StoppedAsync(CancellationToken)

Déclenché après StopAsync(CancellationToken).

StoppingAsync(CancellationToken)

Déclenché avant StopAsync(CancellationToken).

Méthodes d’extension

StartAndStopAsync(IHostedService, CancellationToken)

Démarre et arrête immédiatement le service.

S’applique à

Produit Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)