From 8bfbbd2b297788d8e3351854ed9289d34f01e063 Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Tue, 30 Jul 2019 20:35:33 +0200 Subject: [PATCH] Refactoring. --- Source/MQTTnet/Client/MqttClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/MQTTnet/Client/MqttClient.cs b/Source/MQTTnet/Client/MqttClient.cs index e29e9d0..27b56ff 100644 --- a/Source/MQTTnet/Client/MqttClient.cs +++ b/Source/MQTTnet/Client/MqttClient.cs @@ -257,12 +257,12 @@ namespace MQTTnet.Client { var clientWasConnected = IsConnected; - InitiateDisconnect(); - - IsConnected = false; + TryInitiateDisconnect(); try { + IsConnected = false; + if (_adapter != null) { _logger.Verbose("Disconnecting [Timeout={0}]", Options.CommunicationTimeout); @@ -295,7 +295,7 @@ namespace MQTTnet.Client } } - private void InitiateDisconnect() + private void TryInitiateDisconnect() { lock (_disconnectLock) {