HostingHostBuilderExtensions.RunConsoleAsync 方法

定义

重载

RunConsoleAsync(IHostBuilder, CancellationToken)

启用控制台支持、生成和启动主机,并等待 Ctrl+C 或 SIGTERM 关闭。Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.

RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken)

启用控制台支持、生成和启动主机,并等待 Ctrl+C 或 SIGTERM 关闭。Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.

RunConsoleAsync(IHostBuilder, CancellationToken)

启用控制台支持、生成和启动主机,并等待 Ctrl+C 或 SIGTERM 关闭。Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.

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

参数

hostBuilder
IHostBuilder

要配置的 IHostBuilderThe IHostBuilder to configure.

cancellationToken
CancellationToken

可用于取消控制台的 CancellationTokenA CancellationToken that can be used to cancel the console.

返回

Task

仅当令牌收到信号或应用程序关闭时才会完成的 TaskA Task that only completes when the token is signaled or application is shutdown.

适用于

RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken)

启用控制台支持、生成和启动主机,并等待 Ctrl+C 或 SIGTERM 关闭。Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.

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

参数

hostBuilder
IHostBuilder

要配置的 IHostBuilderThe IHostBuilder to configure.

configureOptions
Action<ConsoleLifetimeOptions>

用于配置 Microsoft.Extensions.Hosting.Internal.ConsoleLifetime 的委托。The delegate for configuring the Microsoft.Extensions.Hosting.Internal.ConsoleLifetime.

cancellationToken
CancellationToken

可用于取消控制台的 CancellationTokenA CancellationToken that can be used to cancel the console.

返回

Task

仅当令牌收到信号或应用程序关闭时才会完成的 TaskA Task that only completes when the token is signaled or application is shutdown.

适用于