HostingHostBuilderExtensions.RunConsoleAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
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。
傳回
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。
傳回
Task,只會在權杖收到訊號或應用程式關閉時才會完成。
- 屬性
例外狀況
取消標記已取消。 此例外狀況會儲存在傳回的工作中。