ScheduleUnity() public static method

Schedules a task to be run on Unity's thread.
public static ScheduleUnity ( Action to_schedule, bool cancel_extensions_on_abort = true ) : ActionTask
to_schedule Action The method to run in the task.
cancel_extensions_on_abort bool Whether or not to cancel extensions automatically when the Task is aborted. Defaults to true.
return ActionTask
示例#1
0
 /// <summary>
 /// Spawns a dedicated thread to run the passed task.
 /// Once the task is completed, the Thread will be recycled.
 /// </summary>
 /// <param name="task">The task to run on the thread as it starts.</param>
 internal void SpawnDedicatedThread(ITask task)
 {
     System.Threading.Thread sys_thread = new System.Threading.Thread(() =>
     {
         try
         {
             Thread t = new Thread();
             lock (threadLock) dedicatedThreads.Add(t);
             t.StartTask(task);
             t.StartThread();
         }
         catch (Exception e)
         {
             Hikari.ScheduleUnity((_) => { throw e; });
         }
     });
     sys_thread.IsBackground = true;
     sys_thread.Start();
 }
示例#2
0
 /// <summary>
 /// Spawns a new thread and adds it to the thread pool.
 /// </summary>
 internal void SpawnThread( )
 {
     lastThreadSpawn = DateTime.Now;
     numThreads++;
     System.Threading.Thread sys_thread = new System.Threading.Thread(() =>
     {
         try
         {
             Thread t = new Thread();
             lock (threadLock) threads.Add(t);
             t.StartThread();
         }
         catch (Exception e)
         {
             Hikari.ScheduleUnity((_) => { throw e; });
         }
     });
     sys_thread.IsBackground = true;
     sys_thread.Start();
 }