How to force PLINQ to create more parallel threads in .NET 4.0 beta 2?

In previous versions of Parallel Extensions, you could set the number of threads:

enumerable.AsParallel(numberOfThreads) 

But now overload is no longer available. How to do it now?

+4
source share
2 answers

In the new version, you can specify it using the extension method .WithDegreeOfParallelism (int degreeOfParallelism). "

IE:

 enumerable.AsParallel().WithDegreeOfParallelism(numberOfThreads) 
+9
source

I really don’t know why this has changed, so I can’t answer the question, but it seems that if the developer determines the number of threads, then the parallel runtime will not be able to perform the operation in most optimal way, based on the currently available hardware threads.

I do not want to indicate the number of threads. The beauty of PLINQ is that it just goes in parallel, without me, to figure out any thread logic.

+4
source

All Articles