C# Language Parallel LINQ (PLINQ) AsUnordered

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.AsParallel()
                          .OrderBy(x => x)
                          .Take(5000)
                          .AsUnordered()
                          .Where(x => x % 2 == 0) // This line won't be affected by ordering
                          .ToList();


Got any C# Language Question?