IHost 接口

定义

程序抽象。A program abstraction.

public interface class IHost : IDisposable
public interface IHost : IDisposable
type IHost = interface
    interface IDisposable
Public Interface IHost
Implements IDisposable
实现

属性

Services

程序配置的服务。The programs configured services.

方法

Dispose()

执行与释放或重置非托管资源关联的应用程序定义的任务。Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(继承自 IDisposable)
StartAsync(CancellationToken)

启动程序。Start the program.

StopAsync(CancellationToken)

尝试正常停止该程序。Attempts to gracefully stop the program.

扩展方法

Run(IHost)

运行应用程序并阻止调用线程,直至主机关闭。Runs an application and block the calling thread until host shutdown.

RunAsync(IHost, CancellationToken)

运行应用程序,并返回仅在触发了令牌或触发了关闭时才完成的任务。Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered.

Start(IHost)

同步启动主机。Starts the host synchronously.

StopAsync(IHost, TimeSpan)

尝试在指定超时内正常停止主机。Attempts to gracefully stop the host with the given timeout.

WaitForShutdown(IHost)

阻止调用线程,直至通过 Ctrl+C 或 SIGTERM 触发关闭。Block the calling thread until shutdown is triggered via Ctrl+C or SIGTERM.

WaitForShutdownAsync(IHost, CancellationToken)

返回在通过给定令牌触发关闭时完成的任务。Returns a Task that completes when shutdown is triggered via the given token.

适用于