ApplicationLifetime Class

Allows consumers to perform cleanup during a graceful shutdown.

Namespace
Microsoft.AspNetCore.Hosting.Internal
Assemblies
  • Microsoft.AspNetCore.Hosting

Syntax

public class ApplicationLifetime : IApplicationLifetime
class Microsoft.AspNetCore.Hosting.Internal.ApplicationLifetime

Properties

Microsoft.AspNetCore.Hosting.Internal.ApplicationLifetime.ApplicationStarted

Triggered when the application host has fully started and is about to wait for a graceful shutdown.

Return type:System.Threading.CancellationToken
public CancellationToken ApplicationStarted { get; }
Microsoft.AspNetCore.Hosting.Internal.ApplicationLifetime.ApplicationStopped

Triggered when the application host is performing a graceful shutdown. All requests should be complete at this point. Shutdown will block until this event completes.

Return type:System.Threading.CancellationToken
public CancellationToken ApplicationStopped { get; }
Microsoft.AspNetCore.Hosting.Internal.ApplicationLifetime.ApplicationStopping

Triggered when the application host is performing a graceful shutdown. Request may still be in flight. Shutdown will block until this event completes.

Return type:System.Threading.CancellationToken
public CancellationToken ApplicationStopping { get; }

Methods

NotifyStarted()

Signals the ApplicationStarted event and blocks until it completes.

public void NotifyStarted()
NotifyStopped()

Signals the ApplicationStopped event and blocks until it completes.

public void NotifyStopped()
StopApplication()

Signals the ApplicationStopping event and blocks until it completes.

public void StopApplication()