示例#1
0
 private void RunKillThread()
 {
     try
     {
         Thread thr = m_conn.m_thread;
         Thread.Sleep(2500);
         try
         {
             if (thr != null && thr.IsAlive)
             {
                 ThreadRegister.MarkThreadDefinitivelyAborted(thr);
                 thr.Abort();
             }
         }
         catch
         {
             // neresime zamykani, tak to tady asi muze spadnout, ale nic se nedeje...
         }
         CallClosed();
     }
     catch (Exception e)
     {
         Logging.Error("Error in RunKillThread:" + e.ToString());
     }
 }
示例#2
0
 private void Run()
 {
     try
     {
         ThreadRegister.RegisterThread(Thread.CurrentThread);
         DoCreateConnection();
         if (AfterCreateConnection != null)
         {
             AfterCreateConnection(this);
         }
         while (!m_breakFlag)
         {
             QElement obj = m_queue.Get();
             try
             {
                 obj.Run();
                 m_statProcessedOkQElements++;
             }
             catch (Exception e)
             {
                 Logging.Error("Error processing queue element:" + e.ToString());
                 m_statProcessedFailQElements++;
             }
         }
     }
     finally
     {
         ThreadRegister.UnregisterThread(Thread.CurrentThread);
     }
 }
示例#3
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                if (Singleton.SwitchToCurrentInstance(args))
                {
                    return;
                }
            }

            IsMono = Type.GetType("Mono.Runtime") != null;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if (DEBUG)
            RunMain(null, args);
#else
            try
            {
                RunMain(null, args);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
#endif
            ThreadRegister.QuitAllThreads();
        }
示例#4
0
 internal void Run()
 {
     try
     {
         try
         {
             lock (m_cancelLock)
             {
                 m_canCancel = true;
             }
             m_result = m_action.RunProc();
         }
         finally
         {
             lock (m_cancelLock)
             {
                 m_canCancel = false;
             }
         }
     }
     catch (ThreadAbortException e)
     {
         m_error = e;
         if (m_canceled)
         {
             // only this QElement is canceled, abort flag should be cleared
             Thread.ResetAbort();
         }
         if (ThreadRegister.IsThreadDefinitivelyAborted(m_thread))
         {
             m_thread.Abort();
         }
     }
     catch (Exception e)
     {
         m_error = e;
         try { m_conn.RepairConnection(); }
         catch { }
     }
     finally
     {
         m_finished = true;
         m_event.Set();
     }
     if (m_callback != null)
     {
         try
         {
             m_callback(this);
         }
         catch (Exception e)
         {
             Logging.Warning("Exception when calling async callback: {0}", e.Message);
         }
     }
 }
示例#5
0
 public void EndClose(IAsyncResult async)
 {
     if (m_thread != null)
     {
         m_thread.Join(100);
         if (m_thread.IsAlive)
         {
             ThreadRegister.MarkThreadDefinitivelyAborted(m_thread);
             m_thread.Abort();
         }
     }
     m_thread       = null;
     m_breakStarted = false;
     m_queue        = null;
     if (async is KillObject)
     {
         ((KillObject)async).EndInvoke();
     }
     else
     {
         EndInvoke(async);
     }
 }