共用方式為


AsyncServiceProviderInjection<TService,TInterface>.GetServiceAsync 方法

定義

多載

GetServiceAsync()

以異步方式傳回擷取的服務。

GetServiceAsync(Boolean)

以異步方式傳回擷取的服務。

GetServiceAsync()

以異步方式傳回擷取的服務。

public System.Threading.Tasks.Task<TInterface> GetServiceAsync();
member this.GetServiceAsync : unit -> System.Threading.Tasks.Task<'Interface (requires 'Interface : null)>
Public Function GetServiceAsync () As Task(Of TInterface)

傳回

Task<TInterface>

服務的實例 TService

例外狀況

如果沒有任何可用的服務類型 TService

備註

對這個方法的多個呼叫會傳回相同的 實例 TInterface

適用於

GetServiceAsync(Boolean)

以異步方式傳回擷取的服務。

public System.Threading.Tasks.Task<TInterface?> GetServiceAsync(bool assumePresent);
member this.GetServiceAsync : bool -> System.Threading.Tasks.Task<'Interface (requires 'Interface : null)>
Public Function GetServiceAsync (assumePresent As Boolean) As Task(Of TInterface)

參數

assumePresent
Boolean

傳回

Task<TInterface>

服務的實例 TService

例外狀況

當為 assumePresenttrue 且沒有任何可用的服務類型 TService 時。

備註

對這個方法的多個呼叫會傳回相同的 實例 TInterface

適用於