Tweaking the parameters of a PLINQ query
This recipe shows how we can manage parallel processing options using a PLINQ query and what these options could affect during a query's execution.
Getting ready
To work through this recipe, you will need Visual Studio 2015. There are no other prerequisites. The source code for this recipe can be found at BookSamples\Chapter7\Recipe3
.
How to do it...
To understand how to manage parallel processing options using a PLINQ query and their effects, perform the following steps:
Start Visual Studio 2015. Create a new C# console application project.
In the
Program.cs
file, add the followingusing
directives:using System; using System.Collections.Generic; using System.Linq; using System.Threading; using static System.Console; using static System.Threading.Thread;
Add the following code snippet below the
Main
method:static string EmulateProcessing(string typeName) { Sleep(TimeSpan.FromMilliseconds( new Random(DateTime.Now.Millisecond).Next(250,350))); WriteLine...