HostingHostBuilderExtensions.UseConsoleLifetime 方法

定義

多載

UseConsoleLifetime(IHostBuilder)

接聽 Ctrl+C 或 SIGTERM,並呼叫 StopApplication() 以啟動關機流程。 這會解除封鎖 RunAsync 和 WaitForShutdownAsync 等延伸模組。

UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>)

接聽 Ctrl+C 或 SIGTERM,並呼叫 StopApplication() 以啟動關機流程。 這會解除封鎖 RunAsync 和 WaitForShutdownAsync 等延伸模組。

UseConsoleLifetime(IHostBuilder)

接聽 Ctrl+C 或 SIGTERM,並呼叫 StopApplication() 以啟動關機流程。 這會解除封鎖 RunAsync 和 WaitForShutdownAsync 等延伸模組。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::Hosting::IHostBuilder ^ UseConsoleLifetime(Microsoft::Extensions::Hosting::IHostBuilder ^ hostBuilder);
public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime (this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder);
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime (this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder);
static member UseConsoleLifetime : Microsoft.Extensions.Hosting.IHostBuilder -> Microsoft.Extensions.Hosting.IHostBuilder
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member UseConsoleLifetime : Microsoft.Extensions.Hosting.IHostBuilder -> Microsoft.Extensions.Hosting.IHostBuilder
<Extension()>
Public Function UseConsoleLifetime (hostBuilder As IHostBuilder) As IHostBuilder

參數

hostBuilder
IHostBuilder

要設定的 IHostBuilder

傳回

IHostBuilder

用於鏈結的相同 IHostBuilder 執行個體。

屬性

適用於

UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>)

接聽 Ctrl+C 或 SIGTERM,並呼叫 StopApplication() 以啟動關機流程。 這會解除封鎖 RunAsync 和 WaitForShutdownAsync 等延伸模組。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::Hosting::IHostBuilder ^ UseConsoleLifetime(Microsoft::Extensions::Hosting::IHostBuilder ^ hostBuilder, Action<Microsoft::Extensions::Hosting::ConsoleLifetimeOptions ^> ^ configureOptions);
public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime (this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> configureOptions);
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime (this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> configureOptions);
static member UseConsoleLifetime : Microsoft.Extensions.Hosting.IHostBuilder * Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> -> Microsoft.Extensions.Hosting.IHostBuilder
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member UseConsoleLifetime : Microsoft.Extensions.Hosting.IHostBuilder * Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> -> Microsoft.Extensions.Hosting.IHostBuilder
<Extension()>
Public Function UseConsoleLifetime (hostBuilder As IHostBuilder, configureOptions As Action(Of ConsoleLifetimeOptions)) As IHostBuilder

參數

hostBuilder
IHostBuilder

要設定的 IHostBuilder

configureOptions
Action<ConsoleLifetimeOptions>

用於設定 ConsoleLifetime 的委派。

傳回

IHostBuilder

用於鏈結的相同 IHostBuilder 執行個體。

屬性

適用於