Ejemplo n.º 1
0
    private static void _initParallelThreadsPool()
    {
        Parallel pool = Parallel.CreateNew(Program.RUNNING_THREADS_IN_TEST_SIMULTANEOUSLY);

        pool.AllDone       += Program._allDoneHandler;
        pool.TaskDone      += Program._taskDoneHandler;
        pool.TaskException += Program._threadExceptionHandler;
        for (int i = 0; i < Program.RUNNING_THREADS_IN_TEST_TOTAL; i++)
        {
            pool.Add(new Pooler.TaskDelegate(Program._testTask), false, ThreadPriority.Lowest);
        }
        Thread.CurrentThread.Priority = ThreadPriority.Highest;
        Program._stopWatch            = Stopwatch.StartNew();
        Program._reportTimer          = new System.Threading.Timer(delegate {
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
            Program._report();
        }, null, 0, 200);
        Program._pool = pool;
    }