Beispiel #1
0
        /// <summary>
        /// 主线程回调
        /// </summary>
        /// <param name="ev"></param>
        private static void MainRunAction(object ev)
        {
            TheardEvent cache = (TheardEvent)ev;

            try
            {
                if (cache.action == null)
                {
                    DebugMod.Log("theard action is null" + cache.name);
                }
                cache.action();
            }
            catch
            {
                DebugMod.LogError("run thunder cathch" + cache.name);
            }
            finally
            {
                if (cache.callback != null)
                {
                    cache.callback();
                }
                Interlocked.Decrement(ref m_iRunThreadsNum);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 新建线程执行
 /// </summary>
 /// <param name="ev"></param>
 /// <returns></returns>
 public static Thread RunAsync(TheardEvent ev)
 {
     Initialize();
     while (m_iRunThreadsNum >= m_iMaxThreads)
     {
         Thread.Sleep(1);
     }
     Interlocked.Increment(ref m_iRunThreadsNum);//数线程加1
     ThreadPool.QueueUserWorkItem(RunAction, ev);
     return(null);
 }
Beispiel #3
0
 /// <summary>
 /// 主线程中执行
 /// </summary>
 /// <param name="ev"></param>
 public static void OnMainThreadQueue(TheardEvent ev)
 {
     if (ev.waitTime > 0)
     {
         lock (m_Instence.m_DelayActionQueue)
         {
             m_Instence.m_DelayActionQueue.Add(ev);
         }
     }
     else
     {
         lock (m_Instence.m_ActionQueue)
         {
             m_Instence.m_ActionQueue.Add(ev);
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// 主线程中执行
 /// </summary>
 /// <param name="ev"></param>
 public static void OnMainThreadQueue(TheardEvent ev)
 {
     if (ev.waitTime > 0)
     {
         lock (m_Instence.m_DelayActionQueue)
         {
             m_Instence.m_DelayActionQueue.Add(ev);
         }
     }
     else
     {
         lock (m_Instence.m_ActionQueue)
         {
             m_Instence.m_ActionQueue.Add(ev);
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// 新建线程执行
 /// </summary>
 /// <param name="ev"></param>
 /// <returns></returns>
 public static Thread RunAsync(TheardEvent ev)
 {
     Initialize();
     while (m_iRunThreadsNum >= m_iMaxThreads)
     {
         Thread.Sleep(1);
     }
     Interlocked.Increment(ref m_iRunThreadsNum);//数线程加1
     ThreadPool.QueueUserWorkItem(RunAction, ev);
     return null;
 }