HikariThreading.ThreadManager.SpawnThread C# (CSharp) Method

SpawnThread() private method

Spawns a new thread and adds it to the thread pool.
private SpawnThread ( ) : void
return void
        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();
        }

Usage Example

示例#1
0
 public void DoesNotDespawnWorkingThread( )
 {
     ThreadManager tm = new ThreadManager(0, 1, TimeSpan.MinValue, TimeSpan.MaxValue, 1, TimeSpan.FromMilliseconds(10));
     tm.SpawnThread();
     ActionTask task = new ActionTask(( _ ) => System.Threading.Thread.Sleep(500), false);
     tm.EnqueueTask(task);
     tm.UnsafeUpdate();
     System.Threading.Thread.Sleep(20);
     tm.UnsafeUpdate();
     Assert.AreEqual(1, tm.NumThreads, "Despawned a thread while working.");
 }
All Usage Examples Of HikariThreading.ThreadManager::SpawnThread