-
Notifications
You must be signed in to change notification settings - Fork 493
Closed
Labels
IoTSDKTracks all IoT SDK issues across the boardTracks all IoT SDK issues across the boardbugSomething isn't working.Something isn't working.underlying library issue
Description
Context
- .NET 5
- DeviceClient SDK 1.36
- AMQP
Description of the issue
DeviceClient.ReceiveAsync(CancellationToken cancellationToken) method does not exit when cancellationToken is cancelled.
The current tests simply verify that the task returns immediately when passed a cancellationToken that is already cancelled.
Code sample exhibiting the issue
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
stoppingToken.Register(() => { _logger.LogInformation("Stopping Token Called"); });
while (!stoppingToken.IsCancellationRequested)
{
using Message receivedMessage = await DeviceClient.ReceiveAsync(stoppingToken);
if (receivedMessage == null) continue;
}
_logger.LogInformation(“Exiting Application”);
}
Console log of the issue
Stopping Token Called
Expected Result
Stopping Token Called
Exiting Application
Workaround
To workaround this I have changed my code to use the ReceiveAsync(TimeSpan) overload, but it feels hacky.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
IoTSDKTracks all IoT SDK issues across the boardTracks all IoT SDK issues across the boardbugSomething isn't working.Something isn't working.underlying library issue