Esempio n. 1
0
        public void endWork()
        {
            if (Interlocked.Exchange(ref m_Run, 0) == 0)
            {
                return;
            }

            if (m_Interpreter != null)
            {
                m_Interpreter.Stop();
            }

            try
            {
                if (m_Client != null)
                {
                    lock (m_Client)
                    {
                        m_Client.Shutdown(SocketShutdown.Both);
                        m_Client.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                try
                {
                    SendLog(ex.Message);
                }
                catch { }
            }
        }
Esempio n. 2
0
        public void endWork()
        {
            if (Interlocked.Exchange(ref m_Run, 0) == 0)
            {
                return;
            }

            m_SignalNewMessage.Set();
            Thread.Sleep(0);

            m_ClearEvent.WaitOne();

            m_ListenerClearEvent.WaitOne();

            if (m_Interpreter != null)
            {
                m_Interpreter.Stop();
            }

            try
            {
                if (m_Client != null)
                {
                    lock (m_Client)
                    {
                        //if (m_Client.Connected)
                        //{
                        //    NetworkStream ns = m_Client.GetStream();
                        //    if (ns != null)
                        //        ns.Close();
                        //}

                        //if (m_Client.Connected)
                        //    m_Client.GetStream().Close();
                        m_Client.Shutdown(SocketShutdown.Both);
                        m_Client.Close();
                    }
                    //m_Client = null;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    SendLog(ex.Message);
                }
                catch { }
            }

            lock (m_Messages)
                m_Messages.Clear();
        }