<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.10" />

Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions

public static class HostingAbstractionsHostExtensions
Provides extension methods for the IHost from the hosting abstractions package.
public static void Run(this IHost host)

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

public static Task RunAsync(this IHost host, CancellationToken token = default)

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.

public static void Start(this IHost host)

Starts the host synchronously.

public static Task StopAsync(this IHost host, TimeSpan timeout)

Attempts to gracefully stop the host with the given timeout.

public static void WaitForShutdown(this IHost host)

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

public static Task WaitForShutdownAsync(this IHost host, CancellationToken token = default)

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