Class BootstrapperLifetime
- Namespace
- Codebelt.Bootstrapper
- Assembly
- Codebelt.Bootstrapper.dll
Listens for Ctrl+C or SIGTERM and initiates shutdown.
public class BootstrapperLifetime : Disposable, IDisposable, IHostLifetime, IHostLifetimeEvents
- Inheritance
-
BootstrapperLifetime
- Implements
- Inherited Members
Constructors
BootstrapperLifetime(IOptions<ConsoleLifetimeOptions>, IHostEnvironment, IHostApplicationLifetime, IOptions<HostOptions>, ILoggerFactory)
Initializes a new instance of the BootstrapperLifetime class.
public BootstrapperLifetime(IOptions<ConsoleLifetimeOptions> options, IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, IOptions<HostOptions> hostOptions, ILoggerFactory loggerFactory)
Parameters
options
IOptions<ConsoleLifetimeOptions>The dependency injected IOptions<TOptions>.
environment
IHostEnvironmentThe dependency injected IHostEnvironment.
applicationLifetime
IHostApplicationLifetimeThe dependency injected IHostApplicationLifetime.
hostOptions
IOptions<HostOptions>The dependency injected IOptions<TOptions>.
loggerFactory
ILoggerFactoryThe dependency injected ILoggerFactory.
Properties
OnApplicationStartedCallback
Triggered when the application host has fully started.
public Action OnApplicationStartedCallback { get; set; }
Property Value
OnApplicationStoppedCallback
Triggered when the application host has completed a graceful shutdown.///
public Action OnApplicationStoppedCallback { get; set; }
Property Value
OnApplicationStoppingCallback
Triggered when the application host is starting a graceful shutdown.
public Action OnApplicationStoppingCallback { get; set; }
Property Value
Methods
OnDisposeManagedResources()
Called when this object is being disposed by either Dispose() or Dispose(Boolean) having disposing
set to true
and Disposed is false
.
protected override void OnDisposeManagedResources()
StopAsync(CancellationToken)
Called from StopAsync(CancellationToken) to indicate that the host is stopping and it's time to shut down.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenUsed to indicate when stop should no longer be graceful.
Returns
WaitForStartAsync(CancellationToken)
Called at the start of StartAsync(CancellationToken) which will wait until it's complete before continuing. This can be used to delay startup until signaled by an external event.
public Task WaitForStartAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenUsed to abort program start.