Partager via


IVsService<T>.GetValueAsync(CancellationToken) Method

Definition

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

public System.Threading.Tasks.Task<T> GetValueAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member GetValueAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T (requires 'T : null)>
Public Function GetValueAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of T)

Parameters

cancellationToken
CancellationToken

A token whose cancellation indicates that the caller no longer is interested in the result. This will not cancel the in-progress loading of packages and/or creation of services as a result of the service retrieval, but this token will result in an expediant cancellation of the returned Task.

Returns

Task<T>

A task representing the service retrieval whose result is the service.

Exceptions

cancellationToken has been canceled.

There was a failure retrieving the service due to one of the following conditions:

  • The service threw an exception during activation. InnerException may include details about the underlying failure.
  • The associated package failed to load. InnerException may include details about the underlying failure.
  • The associated package could not be found, or the package did not correctly proffer the service.
  • The associated package proffered null.
  • The service does not support the requested interface specified by T.
  • The environment has starting shutting down and the retrieval would have resulted in a package load.

Remarks

This method is safe to access from any thread.

Applies to