示例#1
0
        public void Close()
        {
            m_terminating.AtomicInc();
            m_isConnectedFinished.AtomicDec();

            m_isDisconnected.AtomicInc();

            if (s_tracerThread != null)
            {
                if (s_tracerThread.IsAlive)
                {
                    while (IsConnected() && s_tracerThread.IsAlive)
                    {
                        System.Threading.Thread.Sleep(1);
                    }
                }

                lock (this)
                {
                    m_packetBuffers = null;
                }

                if (s_tracerThread.IsAlive)
                {
                    s_tracerThread.Abort();
                }

                s_tracerThread = null;
            }

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

            m_packetPool        = null;
            t_packetBufferIndex = -1;
            SocketBase.ShutdownSockets();

            LogManager.Close();

            m_isInited.AtomicDec();
        }