HostingHostBuilderExtensions.UseConsoleLifetime 方法

定义

重载

UseConsoleLifetime(IHostBuilder)

侦听 Ctrl+C 或 SIGTERM 并调用 StopApplication() 来启动关闭进程。Listens for Ctrl+C or SIGTERM and calls StopApplication() to start the shutdown process. 这将解除阻止 RunAsync 和 WaitForShutdownAsync 等扩展。This will unblock extensions like RunAsync and WaitForShutdownAsync.

UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>)

侦听 Ctrl+C 或 SIGTERM 并调用 StopApplication() 来启动关闭进程。Listens for Ctrl+C or SIGTERM and calls StopApplication() to start the shutdown process. 这将解除阻止 RunAsync 和 WaitForShutdownAsync 等扩展。This will unblock extensions like RunAsync and WaitForShutdownAsync.

UseConsoleLifetime(IHostBuilder)

侦听 Ctrl+C 或 SIGTERM 并调用 StopApplication() 来启动关闭进程。Listens for Ctrl+C or SIGTERM and calls StopApplication() to start the shutdown process. 这将解除阻止 RunAsync 和 WaitForShutdownAsync 等扩展。This will unblock extensions like RunAsync and 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);
static member UseConsoleLifetime : Microsoft.Extensions.Hosting.IHostBuilder -> Microsoft.Extensions.Hosting.IHostBuilder
<Extension()>
Public Function UseConsoleLifetime (hostBuilder As IHostBuilder) As IHostBuilder

参数

hostBuilder
IHostBuilder

要配置的 IHostBuilderThe IHostBuilder to configure.

返回

IHostBuilder

用于链接的相同 IHostBuilder 实例。The same instance of the IHostBuilder for chaining.

适用于

UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>)

侦听 Ctrl+C 或 SIGTERM 并调用 StopApplication() 来启动关闭进程。Listens for Ctrl+C or SIGTERM and calls StopApplication() to start the shutdown process. 这将解除阻止 RunAsync 和 WaitForShutdownAsync 等扩展。This will unblock extensions like RunAsync and 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);
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

要配置的 IHostBuilderThe IHostBuilder to configure.

configureOptions
Action<ConsoleLifetimeOptions>

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

返回

IHostBuilder

用于链接的相同 IHostBuilder 实例。The same instance of the IHostBuilder for chaining.

适用于