From 36b1ed06f04eed719cb3e43e3b5ffde725b26b06 Mon Sep 17 00:00:00 2001 From: Christian <6939810+chkr1011@users.noreply.github.com> Date: Fri, 1 Jul 2022 16:54:53 +0200 Subject: [PATCH] Update MqttClient.cs --- Source/MQTTnet/Server/Internal/MqttClient.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/MQTTnet/Server/Internal/MqttClient.cs b/Source/MQTTnet/Server/Internal/MqttClient.cs index b0465dda..6d2f59e1 100644 --- a/Source/MQTTnet/Server/Internal/MqttClient.cs +++ b/Source/MQTTnet/Server/Internal/MqttClient.cs @@ -188,6 +188,8 @@ namespace MQTTnet.Server // own exception in the reading loop! while (!cancellationToken.IsCancellationRequested) { + await Task.Yield(); + var packet = await ChannelAdapter.ReceivePacketAsync(cancellationToken).ConfigureAwait(false); if (packet == null) { @@ -315,6 +317,10 @@ namespace MQTTnet.Server { packetBusItem.MarkAsFailed(exception); } + finally + { + await Task.Yield(); + } } } catch (OperationCanceledException)