예제 #1
0
 /// <summary>
 /// Processes all remaining tasks. Call this periodically to allow the Dispatcher to handle dispatched tasks.
 /// Only call this inside the thread you want the tasks to process to be processed.
 /// </summary>
 public void ProcessTasks()
 {
     //Debug.Log("DEBUG 1");
     if (UnityThreadHelper.IsWebPlayer ? UnityThreadHelper.WaitOne(dataEvent, 0) : dataEvent.WaitOne(0, false))
     {
         ProcessTasksInternal();
     }
     //Debug.Log("DEBUG 2");
 }
예제 #2
0
 /// <summary>
 /// Blocks the calling thread until the task has been ended or the given timeout value has been reached.
 /// </summary>
 /// <param name="seconds">Time in seconds this method will max wait.</param>
 public void WaitForSeconds(float seconds)
 {
     if (UnityThreadHelper.IsWebPlayer)
     {
         UnityThreadHelper.WaitOne(endedEvent, TimeSpan.FromSeconds(seconds));
     }
     else
     {
         endedEvent.WaitOne(TimeSpan.FromSeconds(seconds));
     }
 }
예제 #3
0
 protected override IEnumerator Do()
 {
     //Debug.Log("DEBUG1");
     while (!(UnityThreadHelper.IsWebPlayer ? UnityThreadHelper.WaitOne(exitEvent, 0) : exitEvent.WaitOne(0, false)))
     {
         //Debug.Log("DEBUG2");
         if (!Dispatcher.ProcessNextTask())
         {
             TaskDistributor.FillTasks(Dispatcher);
             if (Dispatcher.TaskCount == 0)
             {
                 var result = WaitHandle.WaitAny(new WaitHandle[] { exitEvent, TaskDistributor.NewDataWaitHandle });
                 if (result == 0)
                 {
                     return(null);
                 }
                 TaskDistributor.FillTasks(Dispatcher);
             }
         }
     }
     return(null);
 }