From f8c01b2168747985fa9d68055deff719dedbb759 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Sat, 16 Sep 2017 08:13:46 +0200 Subject: [PATCH] fixed invalid operation exception --- MQTTnet.Core/Client/MqttClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index fa81e253..31d20daa 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -340,8 +340,9 @@ namespace MQTTnet.Core.Client private async Task SendAndReceiveAsync(MqttBasePacket requestPacket) where TResponsePacket : MqttBasePacket { + var wait = _packetDispatcher.WaitForPacketAsync(requestPacket, typeof(TResponsePacket), _options.DefaultCommunicationTimeout); await _adapter.SendPacketsAsync(_options.DefaultCommunicationTimeout, requestPacket).ConfigureAwait(false); - return (TResponsePacket)await _packetDispatcher.WaitForPacketAsync(requestPacket, typeof(TResponsePacket), _options.DefaultCommunicationTimeout).ConfigureAwait(false); + return (TResponsePacket)await wait.ConfigureAwait(false); } private ushort GetNewPacketIdentifier()