示例#1
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);
     }
 }
示例#2
0
        public IAsyncResult BeginInvoke(PriorityLevel priority, bool behaveAsStack, IInvokableAction action, AsyncCallback callback)
        {
            if (m_queue == null)
            {
                throw new InternalError("DAE-00005 Connection queue is NULL, probably connection is not open");
            }
            if (IsInInvokerThread)
            {
                try
                {
                    object res = action.RunProc();
                    return(new ValueAsyncResult(res, null));
                }
                catch (Exception err)
                {
                    return(new ValueAsyncResult(null, err));
                }
                //throw new Exception("Invoke called from the same thread");
            }
            QElement elem = new QElement(this, action, callback, m_thread);

            m_queue.Put(priority, behaveAsStack, elem);
            return(elem);
        }