Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

IHost Interface

Definition

Namespace:
Microsoft.Extensions.Hosting
Assembly:
Microsoft.Extensions.Hosting.Abstractions.dll
Package:
Microsoft.Extensions.Hosting.Abstractions v11.0.0-preview.5.26302.115
Source:
IHost.cs
Source:
IHost.cs
Source:
IHost.cs
Source:
IHost.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

A program abstraction.

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

Properties

Name Description
Services

Gets the services configured for the program (for example, using ConfigureServices(Action<HostBuilderContext,IServiceCollection>)).

Methods

Name Description
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from IDisposable)
StartAsync(CancellationToken)

Starts the IHostedService objects configured for the program. The application will run until interrupted or until StopApplication() is called.

StopAsync(CancellationToken)

Attempts to gracefully stop the program.

Extension Methods

Name Description
GetFakeLogCollector(IHost)

Gets the object that collects log records sent to the fake logger.

GetFakeRedactionCollector(IHost)

Gets the object reporting all redactions performed.

Run(IHost)

Runs an application and blocks the calling thread until host shutdown is triggered and all IHostedService instances are stopped.

RunAsync(IHost, CancellationToken)

Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered. The host instance is disposed of after running.

Start(IHost)

Starts the host synchronously.

StopAsync(IHost, TimeSpan)

Attempts to gracefully stop the host with the given timeout.

WaitForShutdown(IHost)

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

WaitForShutdownAsync(IHost, CancellationToken)

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

Applies to


Feedback

Was this page helpful?