IAsyncServiceProvider2.GetServiceAsync(Type, Boolean) Method

Definition

Retrieves an async services but allows the caller to hint that exceptions may not have to be swallowed. It does not guarantee exceptions will be thrown however for failure cases.

public:
 System::Threading::Tasks::Task<System::Object ^> ^ GetServiceAsync(Type ^ serviceType, bool swallowExceptions);
public System.Threading.Tasks.Task<object> GetServiceAsync (Type serviceType, bool swallowExceptions);
public System.Threading.Tasks.Task<object?> GetServiceAsync (Type serviceType, bool swallowExceptions);
abstract member GetServiceAsync : Type * bool -> System.Threading.Tasks.Task<obj>
Public Function GetServiceAsync (serviceType As Type, swallowExceptions As Boolean) As Task(Of Object)

Parameters

serviceType
Type

Service to get.

swallowExceptions
Boolean

When this parameter is true GetServiceAsync will swallow exceptions thrown during the GetServiceAsync call and return null. When this is false exceptions thrown during the get service call may be thrown out of the method. A setting of false does not guarantee exceptions will be thrown for all services failures, or all service types.

Returns

A task representing the service retrieval whose result is the service, or null if the retrieval failed.

Applies to