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()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。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.

適用於