public static ScheduleUnity ( Action |
||
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 |
/// <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(); }
/// <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(); }