Delen via


HostingAbstractionsHostBuilderExtensions.StartAsync Method

Definition

Builds and starts the host.

public static System.Threading.Tasks.Task<Microsoft.Extensions.Hosting.IHost> StartAsync (this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Threading.CancellationToken cancellationToken = default);
static member StartAsync : Microsoft.Extensions.Hosting.IHostBuilder * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.Hosting.IHost>
<Extension()>
Public Function StartAsync (hostBuilder As IHostBuilder, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IHost)

Parameters

hostBuilder
IHostBuilder

The IHostBuilder to start.

cancellationToken
CancellationToken

A CancellationToken that can be used to cancel the start.

Returns

The started IHost.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Start(IHostBuilder).

Applies to