DeviceClient.ReceiveAsync 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.
Overloads
ReceiveAsync(CancellationToken) |
Receive a message from the device queue using the cancellation token. After handling a received message, a client should call CompleteAsync(Message, CancellationToken), AbandonAsync(Message, CancellationToken), or RejectAsync(Message, CancellationToken), and then dispose the message. |
ReceiveAsync(TimeSpan) |
Receive a message from the device queue using a timeout. After handling a received message, a client should call CompleteAsync(Message, CancellationToken), AbandonAsync(Message, CancellationToken), or RejectAsync(Message, CancellationToken), and then dispose the message. |
ReceiveAsync() |
Receive a message from the device queue using the default timeout. After handling a received message, a client should call CompleteAsync(Message), AbandonAsync(Message), or RejectAsync(Message), and then dispose the message. |
ReceiveAsync(CancellationToken)
Receive a message from the device queue using the cancellation token. After handling a received message, a client should call CompleteAsync(Message, CancellationToken), AbandonAsync(Message, CancellationToken), or RejectAsync(Message, CancellationToken), and then dispose the message.
public System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.Message> ReceiveAsync (System.Threading.CancellationToken cancellationToken);
member this.ReceiveAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.Message>
Public Function ReceiveAsync (cancellationToken As CancellationToken) As Task(Of Message)
Parameters
- cancellationToken
- CancellationToken
A cancellation token to cancel the operation.
Returns
The received message or null if there was no message until cancellation token has expired
Exceptions
Thrown when the operation has been canceled.
Thrown when the operation has been canceled. The inner exception will be OperationCanceledException.
Remarks
You cannot reject or abandon messages over MQTT protocol. For more details, see https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-c2d#the-cloud-to-device-message-life-cycle.
Applies to
ReceiveAsync(TimeSpan)
Receive a message from the device queue using a timeout. After handling a received message, a client should call CompleteAsync(Message, CancellationToken), AbandonAsync(Message, CancellationToken), or RejectAsync(Message, CancellationToken), and then dispose the message.
public System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.Message> ReceiveAsync (TimeSpan timeout);
member this.ReceiveAsync : TimeSpan -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.Message>
Public Function ReceiveAsync (timeout As TimeSpan) As Task(Of Message)
Parameters
- timeout
- TimeSpan
Returns
The received message or null if there was no message until the specified time has elapsed.
Remarks
You cannot reject or abandon messages over MQTT protocol. For more details, see https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-c2d#the-cloud-to-device-message-life-cycle.
Applies to
ReceiveAsync()
Receive a message from the device queue using the default timeout. After handling a received message, a client should call CompleteAsync(Message), AbandonAsync(Message), or RejectAsync(Message), and then dispose the message.
public System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.Message> ReceiveAsync ();
member this.ReceiveAsync : unit -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.Client.Message>
Public Function ReceiveAsync () As Task(Of Message)
Returns
The receive message or null if there was no message until the default timeout
Remarks
Applies to
Azure SDK for .NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기