Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 private static void RunAction(object param)
 {
     try
     {
         LoomBase loomObj = (LoomBase)param;
         loomObj.action(loomObj);
     }
     catch
     { }
     finally
     {
         Interlocked.Decrement(ref numThreads);
     }
 }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 4
0
 public static void QueueOnMainThread(LoomBase param, UnityAction <LoomBase> action)
 {
     QueueOnMainThread(param, action, 0f);
 }
Ejemplo n.º 5
0
 public DelayedQueueItem(float time, LoomBase param)
 {
     this.time  = Time.time + time;
     this.param = param;
 }