1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-15 02:13:01 +00:00

Added custom async wait event implementation as the previously used method seemed to not work 100% of the time

This commit is contained in:
Jkorf
2021-10-05 14:31:27 +02:00
parent 4ef20a9637
commit f3102a4dad
7 changed files with 282 additions and 229 deletions
@@ -29,7 +29,7 @@ namespace CryptoExchange.Net.Sockets
private Task? _sendTask;
private Task? _receiveTask;
private Task? _timeoutTask;
private readonly AutoResetEvent _sendEvent;
private readonly AsyncResetEvent _sendEvent;
private readonly ConcurrentQueue<byte[]> _sendBuffer;
private readonly IDictionary<string, string> cookies;
private readonly IDictionary<string, string> headers;
@@ -216,7 +216,7 @@ namespace CryptoExchange.Net.Sockets
_outgoingMessages = new List<DateTime>();
_receivedMessages = new Dictionary<DateTime, int>();
_sendEvent = new AutoResetEvent(false);
_sendEvent = new AsyncResetEvent();
_sendBuffer = new ConcurrentQueue<byte[]>();
_ctsSource = new CancellationTokenSource();
_receivedMessagesLock = new object();
@@ -385,7 +385,7 @@ namespace CryptoExchange.Net.Sockets
if (_closing)
break;
await _sendEvent.WaitOneAsync().ConfigureAwait(false);
await _sendEvent.WaitAsync().ConfigureAwait(false);
if (_closing)
break;