Update MqttClient.cs

This commit is contained in:
Christian
2022-07-01 16:54:53 +02:00
parent 4a982ea228
commit 36b1ed06f0
@@ -188,6 +188,8 @@ namespace MQTTnet.Server
// own exception in the reading loop! // own exception in the reading loop!
while (!cancellationToken.IsCancellationRequested) while (!cancellationToken.IsCancellationRequested)
{ {
await Task.Yield();
var packet = await ChannelAdapter.ReceivePacketAsync(cancellationToken).ConfigureAwait(false); var packet = await ChannelAdapter.ReceivePacketAsync(cancellationToken).ConfigureAwait(false);
if (packet == null) if (packet == null)
{ {
@@ -315,6 +317,10 @@ namespace MQTTnet.Server
{ {
packetBusItem.MarkAsFailed(exception); packetBusItem.MarkAsFailed(exception);
} }
finally
{
await Task.Yield();
}
} }
} }
catch (OperationCanceledException) catch (OperationCanceledException)