你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

DeviceClient.SetReceiveMessageHandlerAsync 方法

定义

设置使用取消令牌从设备队列接收消息的新委托。 处理收到的消息后,客户端应调用 CompleteAsync(Message, CancellationToken)AbandonAsync(Message, CancellationToken)RejectAsync(Message, CancellationToken),然后释放该消息。 如果传递了 null 委托,它将禁用从服务接收消息时触发的回调。

public System.Threading.Tasks.Task SetReceiveMessageHandlerAsync (Microsoft.Azure.Devices.Client.ReceiveMessageCallback messageHandler, object userContext, System.Threading.CancellationToken cancellationToken = default);
member this.SetReceiveMessageHandlerAsync : Microsoft.Azure.Devices.Client.ReceiveMessageCallback * obj * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function SetReceiveMessageHandlerAsync (messageHandler As ReceiveMessageCallback, userContext As Object, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

messageHandler
ReceiveMessageCallback
userContext
Object
cancellationToken
CancellationToken

返回

适用于