Kaynağa Gözat

fix for #762

release/3.x.x
Бессонов Дмитрий 5 yıl önce
ebeveyn
işleme
b12e3bc611
2 değiştirilmiş dosya ile 6 ekleme ve 6 silme
  1. +1
    -1
      Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs
  2. +5
    -5
      Source/MQTTnet/Internal/BlockingQueue.cs

+ 1
- 1
Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs Dosyayı Görüntüle

@@ -349,7 +349,7 @@ namespace MQTTnet.Extensions.ManagedClient
// of the messages, the DropOldestQueuedMessage strategy would
// be unable to know which message is actually the oldest and would
// instead drop the first item in the queue.
var message = _messageQueue.PeekAndWait();
var message = _messageQueue.PeekAndWait(cancellationToken);
if (message == null)
{
continue;


+ 5
- 5
Source/MQTTnet/Internal/BlockingQueue.cs Dosyayı Görüntüle

@@ -8,7 +8,7 @@ namespace MQTTnet.Internal
{
private readonly object _syncRoot = new object();
private readonly LinkedList<TItem> _items = new LinkedList<TItem>();
private readonly ManualResetEvent _gate = new ManualResetEvent(false);
private readonly ManualResetEventSlim _gate = new ManualResetEventSlim(false);

public int Count
{
@@ -32,7 +32,7 @@ namespace MQTTnet.Internal
}
}

public TItem Dequeue()
public TItem Dequeue(CancellationToken cancellationToken = default)
{
while (true)
{
@@ -52,11 +52,11 @@ namespace MQTTnet.Internal
}
}

_gate.WaitOne();
_gate.Wait(cancellationToken);
}
}
public TItem PeekAndWait()
public TItem PeekAndWait(CancellationToken cancellationToken = default)
{
while (true)
{
@@ -73,7 +73,7 @@ namespace MQTTnet.Internal
}
}

_gate.WaitOne();
_gate.Wait(cancellationToken);
}
}



Yükleniyor…
İptal
Kaydet