Пример #1
0
        public static Thread RunAsync(LoomBase param, UnityAction <LoomBase> action)
        {
            param.action = action;

            Initialize();
            while (numThreads >= maxThreads)
            {
                Thread.Sleep(1);
            }

            Interlocked.Increment(ref numThreads);
            ThreadPool.QueueUserWorkItem(RunAction, param);
            return(null);
        }
Пример #2
0
 private static void RunAction(object param)
 {
     try
     {
         LoomBase loomObj = (LoomBase)param;
         loomObj.action(loomObj);
     }
     catch
     { }
     finally
     {
         Interlocked.Decrement(ref numThreads);
     }
 }
Пример #3
0
        public static void QueueOnMainThread(LoomBase param, UnityAction <LoomBase> action, float time)
        {
            param.action = action;

            if (0 != time)
            {
                lock (current.m_QueueItems)
                {
                    current.m_QueueItems.Add(new DelayedQueueItem(time, param));
                }
            }
            else
            {
                lock (current.m_Actions)
                {
                    current.m_Actions.Add(param);
                }
            }
        }
Пример #4
0
 public static void QueueOnMainThread(LoomBase param, UnityAction <LoomBase> action)
 {
     QueueOnMainThread(param, action, 0f);
 }
Пример #5
0
 public DelayedQueueItem(float time, LoomBase param)
 {
     this.time  = Time.time + time;
     this.param = param;
 }