Ejemplo n.º 1
0
        public event LoggingBase.CallbackNotifyer NotifyLogger;//Logger

        /// <summary>
        /// Lets the worker subscribe to the log-event delegating to the observer.
        /// </summary>
        public void Subscribe()
        {
            if (m_Worker == null) m_Worker = new RetPokEngineTest{LogId = Tag.ToString()};
            m_Qworkers.TryGetValue(m_Worker.LogId, out m_Worker);

            if (m_Worker == null)
            {
                m_Worker = new RetPokEngineTest { LogId = Tag.ToString() };
                m_Qworkers.Add(m_Worker.LogId, m_Worker);
            }
            m_Worker.NotifyLogger += NotifyLogger;
            m_Worker.Cancel = false;
        }
Ejemplo n.º 2
0
 protected void InitWorker(RetPokEngineTest worker)
 {
     worker.NotifyLogger += NotifyLogger;
     worker.Cancel = false;
     //worker.Subscribe();
 }
Ejemplo n.º 3
0
        void backgroundWorker_Berekening(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (NotifyLogger!=null) NotifyLogger("Message\t" + e.Argument);

                RetPokEngineTest worker;
                m_Qworkers.TryGetValue(Tag.ToString(), out worker);
                if (worker == null)
                {
                    worker = new RetPokEngineTest();

                } 

                worker.Subscribe();
                worker.Cancel = false;
                worker.DoWork();
                message = worker.Message;
                
            }
            catch (ThreadInterruptedException)
            {
                message = "interrupted!";
                Console.WriteLine("~~~~ thread2 interrupted...");
            }                
            catch (Exception ex)
            {
                message = "interrupted!!" + ex.Message;
                Console.Out.Write(ex);
                Console.WriteLine("~~~~ thread2 error...");
            }
            finally
            {
                Console.WriteLine("~~~~ thread2 initData2 ends ...~~~~");
                //button1.Enabled = true;
            }
            
        }