Tutorial by Examples

This example shows how PLINQ can be used to calculate the even numbers between 1 and 10,000 using multiple threads. Note that the resulting list will won't be ordered! var sequence = Enumerable.Range(1, 10000); var evenNumbers = sequence.AsParallel() .Where(x => x % 2...
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 =&gt...
This example shows how PLINQ can be used to calculate the even numbers between 1 and 10,000 using multiple threads. Order will be maintained in the resulting list, however keep in mind that AsOrdered may hurt performance for a large numbers of elements, so un-ordered processing is preferred when pos...
Ordered sequences may hurt performance when dealing with a large number of elements. To mitigate this, it's possible to call AsUnordered when the sequence order is no longer necessary. var sequence = Enumerable.Range(1, 10000).Select(x => -1 * x); // -1, -2, ... var evenNumbers = sequence.AsPar...

Page 1 of 1