Exemple #1
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();
 }
Exemple #2
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();
 }