Exemplo n.º 1
0
        private void SetParallelLimits()
        {
            int physicalCores = WMI.QueryPhysicalProcessorCount();

            switch (scanTask.ParallelLevel)
            {
            case ParallelLevel.FULL:
            default:
                return;

            case ParallelLevel.REDUCED:
                logger.Info("Parallelism capped at physical core count");
                parallelOptions.MaxDegreeOfParallelism = Math.Max(1, physicalCores);
                break;

            case ParallelLevel.NONE:
                logger.Info("Operating in single-threaded mode");
                parallelOptions.MaxDegreeOfParallelism = 1;
                break;
            }

            logger.Debug("Maximum degree of parallelism set to {0} ", parallelOptions.MaxDegreeOfParallelism);
        }