コード例 #1
0
        public void Shutdown()
        {
            //If already in Shuttingdown state, or Idle, no need to do through shutdown again
            if (m_syncState == SyncConnectorState.ShuttingDown || m_syncState == SyncConnectorState.Idle)
            {
                return;
            }

            m_syncState = SyncConnectorState.ShuttingDown;

            // Cleanup on a worker thread because it will usually kill this thread that's currently running
            // (either the m_send_loop or m_rcvLoop)
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                m_log.WarnFormat("{0}: Shutting down connection", LogHeader);

                // Close the connection
                m_tcpConnection.Client.Close();
                m_tcpConnection.Close();

                m_regionSyncModule.CleanupAvatars();

                RequestSendRecvLoopsStop();
                // Abort receive and send loop
                //m_rcvLoop.Abort();
                //m_send_loop.Abort();
                m_rcvLoop.Join();
                m_send_loop.Join();

                m_syncState     = SyncConnectorState.Idle;
                m_tcpConnection = null;
            });
        }