The WithDegreeOfParallelism operator sets an upper limit of the number of partitions that will be processed at once by PLINQ.
PLINQ breaks up your source sequence into partitions, which are then processed simultaneously.
public static ParallelQuery<T> WithDegreeOfParallelism<T>( this ParallelQuery<T> source, int degreeOfParallelism )
using System; using System.Linq; using System.Collections; using System.Collections.Generic; class Program// w ww . jav a 2 s. co m { static void Main(string[] args) { string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"}; IEnumerable<string> results = codeNames .AsParallel() .WithDegreeOfParallelism(2) .Where(p => p.Contains('o')) .Select(p => p); foreach (string president in results) { Console.WriteLine("Match: {0}", president); } } }