IotHubBaseClient.SetDirectMethodCallbackAsync Method

Definition

Sets the callback for all direct method calls from the service. This instance must be opened already.

public System.Threading.Tasks.Task SetDirectMethodCallbackAsync (Func<Microsoft.Azure.Devices.Client.DirectMethodRequest,System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.DirectMethodResponse>> directMethodCallback, System.Threading.CancellationToken cancellationToken = default);
member this.SetDirectMethodCallbackAsync : Func<Microsoft.Azure.Devices.Client.DirectMethodRequest, System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.DirectMethodResponse>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function SetDirectMethodCallbackAsync (directMethodCallback As Func(Of DirectMethodRequest, Task(Of DirectMethodResponse)), Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

directMethodCallback
Func<DirectMethodRequest,Task<DirectMethodResponse>>

The callback to be invoked when any method is invoked by the cloud service.

cancellationToken
CancellationToken

A cancellation token to cancel the operation.

Returns

Exceptions

Thrown when the operation has been canceled.

Remarks

Calling this API more than once will result in the callback set last overwriting any previously set callback. A method callback can be unset by setting directMethodCallback to null.

Applies to