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

Task,只會在權杖收到訊號或應用程式關閉時才會完成。A 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

Task,只會在權杖收到訊號或應用程式關閉時才會完成。A Task that only completes when the token is signaled or application is shutdown.

適用於