C# Language WithDegreeOfParallelism


Example

The degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query.

var sequence = Enumerable.Range(1, 10000);
var evenNumbers = sequence.AsParallel()
                          .WithDegreeOfParallelism(4)
                          .Where(x => x % 2 == 0);