Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Created November 12, 2017 14:55
Show Gist options
  • Save luisdeol/2acbf56e29aadf85451ddbc497585862 to your computer and use it in GitHub Desktop.
Save luisdeol/2acbf56e29aadf85451ddbc497585862 to your computer and use it in GitHub Desktop.
Using PLINQ: AsParallel
namespace MultiThreadingExamples
{
class Program
{
static void Main(string[] args)
{
var aLotOfNumbers = Enumerable.Range(0, 100);
var parallelEvenNumbers = aLotOfNumbers
.AsParallel()
.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