From 3ff5806dbb4b081dbeeaab047f2343491cbed0ce Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Thu, 3 Oct 2019 15:26:33 +0200 Subject: [PATCH] Dispose queue in managed client. --- .../MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs | 1 + Source/MQTTnet/Internal/BlockingQueue.cs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs b/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs index 0607d93..50310be 100644 --- a/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs +++ b/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs @@ -252,6 +252,7 @@ namespace MQTTnet.Extensions.ManagedClient _maintainConnectionTask = null; } + _messageQueue.Dispose(); _messageQueueLock.Dispose(); _mqttClient.Dispose(); } diff --git a/Source/MQTTnet/Internal/BlockingQueue.cs b/Source/MQTTnet/Internal/BlockingQueue.cs index 871c40a..6225105 100644 --- a/Source/MQTTnet/Internal/BlockingQueue.cs +++ b/Source/MQTTnet/Internal/BlockingQueue.cs @@ -4,7 +4,7 @@ using System.Threading; namespace MQTTnet.Internal { - public class BlockingQueue + public class BlockingQueue : IDisposable { private readonly object _syncRoot = new object(); private readonly LinkedList _items = new LinkedList(); @@ -108,5 +108,10 @@ namespace MQTTnet.Internal _items.Clear(); } } + + public void Dispose() + { + _gate.Dispose(); + } } }