[.NET PLINQ] Easy Parallel Tasks processing
With just one more line you transform a LINQ into a parallel query

Why PLINQ?
You probably faced this problem at least once in your career: You are creating a program or a simple script to get some data, process in some way and get the result but with a lot of data, or maybe you just need to call an API multiple times for each customer you have on your database, you finish your script and start running it, it works, but rapidly you see that it would take hours, maybe days with that program running to finish, or even if that didn’t happen with you, and you’re just trying to learn something new, today I’m trying to share something that I learned recently and I found very interesting and productive, it’s called PLINQ which means Parallel LINQ.
So, LINQ everybody knows doesn’t? Or at least heard about it, then with just with a few more lines you can configure your LINQ query to be processed in parallel, with many interesting configurable options like max number of processors that the code should use.
How to Implement
First, you’ll need something to be processed, let’s separate processing into multiple .NET Tasks, I made this Tasks generator to simplify, in a real world scenario this would be the place to put your code in. Consider this implementation:

With just LINQ we already could start processing our tasks:

In this example, I’m generating 10 sample Tasks that will take a random time between 3 and 10 seconds to complete.
If we execute this code, it gets processed synchronously, but we can improve this processing by just adding some more lines:

As I promised, you can additionally just call .AsParallel() to make use of PLINQ, but you have some other parameters to customize and get even more benefits from it. Feel free to share this with your team if you found it useful too, or just keep the code snippet saved if you often need this approach.
Here you can find the full example implementation:
Official Microsoft documentation about PLINQ: Microsoft Reference