File: IHostApplicationLifetime.cs
Web Access
Project: src\src\libraries\Microsoft.Extensions.Hosting.Abstractions\src\Microsoft.Extensions.Hosting.Abstractions.csproj (Microsoft.Extensions.Hosting.Abstractions)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Threading;
 
namespace Microsoft.Extensions.Hosting
{
    /// <summary>
    /// Allows consumers to be notified of application lifetime events. This interface is not intended to be user-replaceable.
    /// </summary>
    public interface IHostApplicationLifetime
    {
        /// <summary>
        /// Gets a cancellation token that is triggered when the application host has fully started and is about to wait
        /// for a graceful shutdown.
        /// </summary>
        CancellationToken ApplicationStarted { get; }
 
        /// <summary>
        /// Gets a cancellation token that is triggered when the application host is starting a graceful shutdown.
        /// Requests might still be in flight. Shutdown will block until all callbacks registered on this token have completed.
        /// </summary>
        CancellationToken ApplicationStopping { get; }
 
        /// <summary>
        /// Gets a cancellation token that is triggered when the application host has completed a graceful shutdown.
        /// All requests should be complete at this point.
        /// The application will not exit until all callbacks registered on this token have completed.
        /// </summary>
        CancellationToken ApplicationStopped { get; }
 
        /// <summary>
        /// Requests termination of the current application.
        /// </summary>
        void StopApplication();
    }
}