IHost IHost IHost Interface


A program abstraction.

public interface IHost : IDisposable
type IHost = interface
    interface IDisposable
Public Interface IHost
Implements IDisposable


Services Services Services

The programs configured services.


StartAsync(CancellationToken) StartAsync(CancellationToken) StartAsync(CancellationToken)

Start the program.

StopAsync(CancellationToken) StopAsync(CancellationToken) StopAsync(CancellationToken)

Attempts to gracefully stop the program.

Extension Methods

Run(IHost) Run(IHost) Run(IHost)

Runs an application and block the calling thread until host shutdown.

RunAsync(IHost, CancellationToken) RunAsync(IHost, CancellationToken) RunAsync(IHost, CancellationToken)

Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered.

Start(IHost) Start(IHost) Start(IHost)

Starts the host synchronously.

StopAsync(IHost, TimeSpan) StopAsync(IHost, TimeSpan) StopAsync(IHost, TimeSpan)

Attempts to gracefully stop the host with the given timeout.

WaitForShutdown(IHost) WaitForShutdown(IHost) WaitForShutdown(IHost)

Block the calling thread until shutdown is triggered via Ctrl+C or SIGTERM.

WaitForShutdownAsync(IHost, CancellationToken) WaitForShutdownAsync(IHost, CancellationToken) WaitForShutdownAsync(IHost, CancellationToken)

Returns a Task that completes when shutdown is triggered via the given token.

Applies to