From the course: Advanced Threading in C#

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

PLINQ demo

PLINQ demo - C# Tutorial

From the course: Advanced Threading in C#

Start my 1-month free trial

PLINQ demo

- [Instructor] Now let's do a simple demo for PLINQ. I'll just called it PLinqIntroduction. In this case, what we're going to do is take a list. Create a list of quite a lot of numbers, and then look for the prime numbers in that list. So something like var list = Enumerable.Range, one all the way to, let's say 100,000, and then we want to find all the prime numbers associated with that range, and say AsParallel(), and then add a Where condition, which would take in a (mumbles) expression, and if that number is one, then we surely want to return false. If that number happens to be two, we return true, because two happens to be a prime number. And after that, if x %2 == 0, that means it's divided by two, and then we should be able to return a false. Well, next we're going to have to look for a boundary, which would be using up the math function, Math.Floor. And then you have (Math.Sqrt, use (x)). Now honestly, this isn't very important. This logic could be a very simple logic, that…

Contents