<PackageReference Include="Microsoft.Extensions.Hosting" Version="11.0.0-preview.7.26381.103" />

Microsoft.Extensions.Hosting.Internal.ConsoleLifetime

public class ConsoleLifetime : IHostLifetime, IDisposable
Listens for Ctrl+C or SIGTERM and initiates shutdown.
public ConsoleLifetime(IOptions<ConsoleLifetimeOptions> options, IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, IOptions<HostOptions> hostOptions)

Initializes a ConsoleLifetime instance using the specified console lifetime options, host environment, host application lifetime, and host options.

public ConsoleLifetime(IOptions<ConsoleLifetimeOptions> options, IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, IOptions<HostOptions> hostOptions, ILoggerFactory loggerFactory)

Initializes a ConsoleLifetime instance using the specified console lifetime options, host environment, host options, and logger factory.

public void Dispose()

Unregisters the shutdown handlers and disposes the application start and application stop registrations.

public Task StopAsync(CancellationToken cancellationToken)

This method does nothing.

public Task WaitForStartAsync(CancellationToken cancellationToken)

Registers the application start, application stop and shutdown handlers for this application.