共用方式為


IAsyncServiceProvider2 Interface

Definition

Provides a mechanism for retrieving proffered services. This is the async equivalent of IServiceProvider and should be used in asynchronous contexts to avoid blocking calling threads.

public interface class IAsyncServiceProvider2 : Microsoft::VisualStudio::Shell::IAsyncServiceProvider
public interface IAsyncServiceProvider2 : Microsoft.VisualStudio.Shell.IAsyncServiceProvider
type IAsyncServiceProvider2 = interface
    interface IAsyncServiceProvider
Public Interface IAsyncServiceProvider2
Implements IAsyncServiceProvider
Derived
Implements

Remarks

This interface is safe to access from any thread.

Prefer IAsyncServiceProvider3 and ServiceExtensions over using this interface directly to avoid unexpected blocking RPC calls when casting the resulting service to a specific interface. Both also provide more consistent throwing behavior.

Methods

GetServiceAsync(Type, Boolean)

Retrieves a proffered service asynchronously, specifying a hint whether to throw an exception if it could not be retrieved. It does not, however, guarantee exceptions will be thrown for all failure cases.

GetServiceAsync(Type)

Retrieves a proffered service asynchronously.

(Inherited from IAsyncServiceProvider)

Extension Methods

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean, CancellationToken)

Retrieves a proffered service asynchronously, specifying whether to throw an exception if it could not be retrieved.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean)

Retrieves a proffered service asynchronously, specifying whether to throw an exception if it could not be retrieved.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, CancellationToken)

Retrieves a proffered service asynchronously, throwing an exception if it could not be retrieved.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider)

Retrieves a proffered service asynchronously, throwing an exception if it could not be retrieved.

Applies to