Beispiel #1
0
 private void SendTask()
 {
     while (client != null && client.Connected)
     {
         BinaryObj binObj = null;
         try
         {
             if (sendQueue.TryDequeue(out binObj))
             {
                 stream.Write(binObj.bytes, 0, binObj.length);
                 rps++;
                 //stream.Flush();
             }
         }
         catch (OperationCanceledException) { }
         catch (Exception e)
         {
             LogError?.Invoke(e.ToString());
         }
         finally
         {
             if (binObj != null)
             {
                 binObj.ResetOjb();
                 BinaryObjPool.Checkin(binObj);
             }
         }
     }
     LogInfo?.Invoke("SimpleTcpClient SendTask shutdown");
 }
 private void SendTask()
 {
     while (socket != null && socket.Connected)
     {
         BinaryObj binObj = null;
         try
         {
             if (sendQueue.TryDequeue(out binObj))
             {
                 socket.Send(binObj.bytes, 0, binObj.length, SocketFlags.None);
             }
         }
         catch (OperationCanceledException) { }
         catch (Exception e)
         {
             LogError?.Invoke(e.ToString());
         }
         finally
         {
             if (binObj != null)
             {
                 binObj.ResetOjb();
                 BinaryObjPool.Checkin(binObj);
             }
         }
     }
     LogInfo?.Invoke("SimpleTcpClient SendTask shutdown");
 }
Beispiel #3
0
        public void Enqueue(IBinaryProcess BinObjIn)
        {
            var binObj = BinObjIn.ToBytes();

            Enqueue(binObj.bytes);
            BinaryObjPool.Checkin(binObj);
        }