Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Created November 12, 2017 15:05
Show Gist options
  • Save luisdeol/b48b2f07a97e41f8c95e07e4508f7fa5 to your computer and use it in GitHub Desktop.
Save luisdeol/b48b2f07a97e41f8c95e07e4508f7fa5 to your computer and use it in GitHub Desktop.
Using PLINQ: ForAll
namespace MultiThreadingExamples
{
class Program
{
static void Main(string[] args)
{
var anIncrediblyBigSet = Enumerable.Range(0, 10);
var parallelEvenNumbers = anIncrediblyBigSet
.AsParallel()
.AsOrdered() // it does not matter if it is ordered. ForAll removes any specified order.
.Where(number => number % 2 == 0);
parallelEvenNumbers.ForAll(even => Console.WriteLine($"Number {even}"));
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment