Example #1
0
 /// <summary>
 /// Get instance of the ParallelFor class for singleton pattern and
 /// update the number of threads if appropriate.
 /// </summary>
 /// <param name="threadCount">The thread count.</param>
 /// <returns></returns>
 public static ParallelFor GetInstance(int threadCount)
 {
     if (instance == null)
     {
         instance             = new ParallelFor();
         instance.threadCount = threadCount;
         instance.Initialize();
     }
     else
     {
         // Ensure we have the correct number of threads.
         if (instance.workerThreads.Count != threadCount)
         {
             instance.Terminate();
             instance.threadCount = threadCount;
             instance.Initialize();
         }
     }
     return(instance);
 }