public void SendCommand(TcpState state, PoolCommand command) { tcpClientSend.Set(); try { var buffer = command.GetBytes(); state.Stream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(processSend), state); } catch (Exception ex) { LogHelper.Error(ex.Message, ex); this.CloseSocket(state); } tcpClientSend.WaitOne(); }