2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 13:33:13 +00:00

Send Lock

This commit is contained in:
2019-11-20 20:57:31 +03:00
parent 5c995a7def
commit 5a0673b403
2 changed files with 50 additions and 108 deletions

View File

@ -55,7 +55,7 @@ namespace Esiur.Net.Sockets
bool asyncSending;
bool began = false;
SocketState state = SocketState.Initial;
public event ISocketReceiveEvent OnReceive;
@ -240,19 +240,20 @@ namespace Esiur.Net.Sockets
{
try
{
if (sendBufferQueue.Count > 0)
lock (sendLock)
{
lock (sendLock)
if (sendBufferQueue.Count > 0)
{
byte[] data = sendBufferQueue.Dequeue();
//Console.WriteLine(Encoding.UTF8.GetString(data));
sock.SendAsync(new ArraySegment<byte>(data), SocketFlags.None).ContinueWith(DataSent);
}
}
else
{
asyncSending = false;
else
{
asyncSending = false;
}
}
}
catch (Exception ex)