Table of Contents

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 IHostEnvironment

The dependency injected IHostEnvironment.

applicationLifetime IHostApplicationLifetime

The dependency injected IHostApplicationLifetime.

hostOptions IOptions<HostOptions>

The dependency injected IOptions<TOptions>.

loggerFactory ILoggerFactory

The dependency injected ILoggerFactory.

Properties

OnApplicationStartedCallback

Triggered when the application host has fully started.

public Action OnApplicationStartedCallback { get; set; }

Property Value

Action

OnApplicationStoppedCallback

Triggered when the application host has completed a graceful shutdown.///

public Action OnApplicationStoppedCallback { get; set; }

Property Value

Action

OnApplicationStoppingCallback

Triggered when the application host is starting a graceful shutdown.

public Action OnApplicationStoppingCallback { get; set; }

Property Value

Action

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 CancellationToken

Used to indicate when stop should no longer be graceful.

Returns

Task

A Task that represents the asynchronous operation.

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 CancellationToken

Used to abort program start.

Returns

Task

A Task that represents the asynchronous operation.

See Also