ParallelOptions op = new ParallelOptions(); op.MaxDegreeOfParallelism = Environment.ProcessorCount / 2 ; Parallel.ForEach(tokensFiles, op, filePath => DoSomething());