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

适用于