IVsService<T>.GetValueOrNullAsync(CancellationToken) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves a proffered service asynchronously; otherwise, null
if it could not be retrieved.
public System.Threading.Tasks.Task<T?> GetValueOrNullAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member GetValueOrNullAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T (requires 'T : null)>
Public Function GetValueOrNullAsync (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
A task whose result is one of the following:
- The service if the request was successful.
null
if the service threw an exception during activation. InnerException may include details about the underlying failure.null
if the associated package failed to load. InnerException may include details about the underlying failure.null
if the associated package profferednull
.null
if the associated package could not be found, or the package did not correctly proffer the service.null
if the environment has starting shutting down and the retrieval would have resulted in a package load.- Otherwise;
null
if there was any other failure retrieving the service.true
.
Exceptions
cancellationToken
has been canceled.
Remarks
This method is safe to access from any thread.