From d59165b70dc1ce258cf6ade18d642fcf1ffb84be Mon Sep 17 00:00:00 2001 From: "a.bozhenov" Date: Mon, 12 Aug 2019 22:04:06 +0300 Subject: [PATCH] Update SocketClient.cs --- ZeroLevel/Services/Network/SocketClient.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ZeroLevel/Services/Network/SocketClient.cs b/ZeroLevel/Services/Network/SocketClient.cs index 9d2ed97..cd7cd1a 100644 --- a/ZeroLevel/Services/Network/SocketClient.cs +++ b/ZeroLevel/Services/Network/SocketClient.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Net; using System.Net.Sockets; using System.Threading; +using System.Threading.Tasks; using ZeroLevel.Services.Pools; using ZeroLevel.Services.Serialization; @@ -337,8 +338,7 @@ namespace ZeroLevel.Network private void ReceiveAsyncCallback(IAsyncResult ar) { try - { - EnsureConnection(); + { var count = _stream.EndRead(ar); if (count > 0) { @@ -350,9 +350,10 @@ namespace ZeroLevel.Network // TODO or not TODO Thread.Sleep(1); } + EnsureConnection(); if (Status == SocketClientStatus.Working || Status == SocketClientStatus.Initialized) - { + { _stream.BeginRead(_buffer, 0, DEFAULT_RECEIVE_BUFFER_SIZE, ReceiveAsyncCallback, null); } }