Degree of parallelism is the maximum number of ‘concurrently’ executing tasks that will be used to process the query. A query could become a long running one if it is waiting for a resource to be released or hardware to respond. PLINQ can parallelize this query by calling WithDegreeOfParallelism (which sets the maximum processor cores) after AsParallel().
AsParallel() method enables parallelization of a query.
The degreeOfParallelism is less than 1 or greater than 63. The WithDegreeOfParallelism method sets the degree of parallelism to use in a query. Let us see how to set the maximum number of processor cores to 3 using this method.
Depending on the number of cores you have, PLINQ may process that many chunks of data at once. So if you have a quadcore machine, it would be 4 threads. However remember that specifying WithDegreeOfParallelism as 8 on a quad core machine wouldn't really improve performance because only 4 threads could be active at the same time. Having said that, for File I/O ops, I usually specify a number greater than the number of cores.
Will you give this article a +1 ? Thanks in advance