示例#1
0
 //+------------------------------------------------------------------+
 //| Dealer stopping                                                  |
 //+------------------------------------------------------------------+
 public void Stop()
 {
     //--- if manager interface was created
     if (m_manager != null)
     {
         //--- unsubscribe from notifications
         m_manager.Unsubscribe(this);
         //--- unsubscribe from requests
         m_manager.RequestUnsubscribe(m_request_sink);
         //--- unsubscribe from orders
         m_manager.OrderUnsubscribe(m_order_sink);
     }
     //--- 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;
     }
 }