/// <summary> /// 关闭连接并释放所有相关资源。 /// </summary> public void Close() { if (m_Socket == null) { return; } m_EventPool.Clear(); m_Active = false; try { m_Socket.Shutdown(SocketShutdown.Both); } catch { } finally { m_Socket.Close(); m_Socket = null; if (NetworkChannelClosed != null) { NetworkChannelClosed(this); } } }
/// <summary> /// 关闭连接并释放所有相关资源。 /// </summary> public void Close() { lock (this) { if (m_Socket == null) { return; } m_Active = false; try { m_Socket.Shutdown(SocketShutdown.Both); } catch { } finally { m_Socket.Close(); m_Socket = null; if (NetworkChannelClosed != null) { NetworkChannelClosed(this); } } m_SentPacketCount = 0; m_ReceivedPacketCount = 0; lock (m_SendPacketPool) { m_SendPacketPool.Clear(); } m_ReceivePacketPool.Clear(); lock (m_HeartBeatState) { m_HeartBeatState.Reset(true); } } }
private EventPool RetrieveChanges(ChangesMonitor source) { if (LostLifeChanges.Count == 0) { return(source.Wait(IsCancel)); } // we failed last time and there are unprocessed changes var changes = new EventPool(LostLifeChanges); LostLifeChanges.Clear(); return(changes); }