.net.net-4.0plinqparallel-extensions.net-4.0-beta-2

How to make PLINQ to spawn more concurrent threads in .NET 4.0 beta 2?


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

enumerable.AsParallel(numberOfThreads)

But now that overload is not available anymore. How to do it now?


Solution

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

    IE:

    enumerable.AsParallel().WithDegreeOfParallelism(numberOfThreads)