ServiceExtensions.GetServiceAsync Method

Definition

Overloads

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider)

Gets a service interface from a service provider asynchronously.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean)

Gets a service interface from a service provider asynchronously.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider)

Gets a service interface from a service provider asynchronously.

public:
generic <typename TService, typename TInterface>
 where TInterface : class[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TInterface> ^ GetServiceAsync(Microsoft::VisualStudio::Shell::IAsyncServiceProvider ^ asp);
public static System.Threading.Tasks.Task<TInterface> GetServiceAsync<TService,TInterface> (this Microsoft.VisualStudio.Shell.IAsyncServiceProvider asp) where TInterface : class;
static member GetServiceAsync : Microsoft.VisualStudio.Shell.IAsyncServiceProvider -> System.Threading.Tasks.Task<'Interface (requires 'Interface : null)> (requires 'Interface : null)
<Extension()>
Public Function GetServiceAsync(Of TService, TInterface) (asp As IAsyncServiceProvider) As Task(Of TInterface)

Type Parameters

TService

The service type

TInterface

The interface type

Parameters

asp
IAsyncServiceProvider

The async service provider

Returns

Task<TInterface>

The requested service interface. Never null.

Exceptions

Either the service could not be acquired, or the service does not support the requested interface.

Applies to

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean)

Gets a service interface from a service provider asynchronously.

public static System.Threading.Tasks.Task<TInterface?> GetServiceAsync<TService,TInterface> (this Microsoft.VisualStudio.Shell.IAsyncServiceProvider asp, bool throwOnFailure = true) where TInterface : class;
static member GetServiceAsync : Microsoft.VisualStudio.Shell.IAsyncServiceProvider * bool -> System.Threading.Tasks.Task<'Interface (requires 'Interface : null)> (requires 'Interface : null)
<Extension()>
Public Function GetServiceAsync(Of TService, TInterface) (asp As IAsyncServiceProvider, Optional throwOnFailure As Boolean = true) As Task(Of TInterface)

Type Parameters

TService

The service type

TInterface

The interface type

Parameters

asp
IAsyncServiceProvider

The async service provider

throwOnFailure
Boolean

Determines how a failure to get the requested service interface is handled. If true, an exception is thrown; if false, null is returned.

Returns

Task<TInterface>

The requested service interface, if it could be obtained; otherwise null if throwOnFailure is false.

Exceptions

Either the service could not be acquired, or the service does not support the requested interface.

Applies to