Exemplo n.º 1
0
 public void SendMsg(IProtocol proto)
 {
     SerializeControl.Instance.Serialize(_sendMarshalStream, proto);
     lock (_sendTransitOct)
     {
         _sendTransitOct.Write(_sendMarshalStream.Oct);
     }
     _sendMarshalStream.Clear();
     _sendEvent.Set();
 }
Exemplo n.º 2
0
        public void Close()
        {
            _receiveTransitStream.Clear();
            _protocols.Clear();

            //先关闭线程,再关闭socket,这样Receive方法中就不会因为捕获到异常而再次将Close请求放回主线程
            CloseSendThd();
            CloseReceiveThd();

            if (_socket != null)
            {
                _socket.Close();
                _socket = null;
            }

            _actions.Clear();
        }