Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Created November 12, 2017 14:59
Show Gist options
  • Save luisdeol/b4136d8d93bc6437c65468c2c553d230 to your computer and use it in GitHub Desktop.
Save luisdeol/b4136d8d93bc6437c65468c2c553d230 to your computer and use it in GitHub Desktop.
Using PLINQ: AsOrdered
namespace MultiThreadingExamples
{
class Program
{
static void Main(string[] args)
{
var aLotOfNumbers = Enumerable.Range(0, 100);
var parallelEvenNumbers = aLotOfNumbers
.AsParallel()
.AsOrdered()
.Where(number => number % 2 == 0)
.ToArray();
foreach(var evenNumber in parallelEvenNumbers)
Console.WriteLine(evenNumber);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment