Delen via


AsyncServiceProviderInjection<TService,TInterface>.GetServiceAsync Method

Definition

Overloads

GetServiceAsync()

Asynchronously returns the retrieved service.

GetServiceAsync(Boolean)

Asynchronously returns the retrieved service.

GetServiceAsync()

Asynchronously returns the retrieved service.

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)

Returns

Task<TInterface>

An instance of the TService service.

Exceptions

If there isn't any service of type TService available.

Remarks

Multiple calls to this method will return the same instance of TInterface.

Applies to

GetServiceAsync(Boolean)

Asynchronously returns the retrieved service.

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)

Parameters

assumePresent
Boolean

Returns

Task<TInterface>

An instance of the TService service.

Exceptions

When assumePresent is true and there isn't any service of type TService available.

Remarks

Multiple calls to this method will return the same instance of TInterface.

Applies to