HostingHostBuilderExtensions.RunConsoleAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| RunConsoleAsync(IHostBuilder, CancellationToken) |
啟用主控台支援,建置並啟動主機,等待 Ctrl+C 或 SIGTERM 關閉。 |
| RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken) |
啟用主控台支援,建置並啟動主機,等待 Ctrl+C 或 SIGTERM 關閉。 |
RunConsoleAsync(IHostBuilder, CancellationToken)
啟用主控台支援,建置並啟動主機,等待 Ctrl+C 或 SIGTERM 關閉。
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Threading.CancellationToken cancellationToken = default);
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member RunConsoleAsync : Microsoft.Extensions.Hosting.IHostBuilder * System.Threading.CancellationToken -> System.Threading.Tasks.Task
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
IHostBuilder要設定。
- cancellationToken
- CancellationToken
CancellationToken A可以用來取消主機。
傳回
Task只有在觸發標記或關機時才會完成。
- 屬性
例外狀況
取消令牌也被取消了。 此例外會儲存在回傳的任務中。
適用於
RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken)
啟用主控台支援,建置並啟動主機,等待 Ctrl+C 或 SIGTERM 關閉。
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> configureOptions, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> configureOptions, System.Threading.CancellationToken cancellationToken = default);
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member RunConsoleAsync : Microsoft.Extensions.Hosting.IHostBuilder * Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
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
IHostBuilder要設定。
- configureOptions
- Action<ConsoleLifetimeOptions>
代表來配置 ConsoleLifetime.
- cancellationToken
- CancellationToken
CancellationToken A可以用來取消主機。
傳回
Task只有在觸發標記或關機時才會完成。
- 屬性
例外狀況
取消令牌也被取消了。 此例外會儲存在回傳的任務中。