AsUnordered
suggest changeOrdered 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.AsParallel()
.OrderBy(x => x)
.Take(5000)
.AsUnordered()
.Where(x => x % 2 == 0) // This line won't be affected by ordering
.ToList();
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents