Ejemplo n.º 1
0
        public void Stop()
        {
            //--- if manager interface was created
            if (m_manager != null)
            {
                //--- unsubscribe from notifications
                m_manager.Unsubscribe(this);
                //--- unsubscribe from requests
                m_manager.DealUnsubscribe(_dealSink);
            }
            //--- wait for dealing thread exit
            if (m_thread_dealer != null)
            {
                //--- set thread stop flag
                Interlocked.Exchange(ref m_stop_flag, 1);
                //--- set answer event
                m_event_answer.Set();
                //--- release dealer thread from waiting state
                if (!m_event_request.WaitOne(0))
                {
                    m_event_request.Set();
                }
                //--- wait for thread exit
                m_thread_dealer.Join(Timeout.Infinite);
                m_thread_dealer = null;
            }

            m_manager.Disconnect();
        }