Posts

Showing posts from April, 2024

PLINQ IN .Net

PLINQ Methods Example PLINQ Methods Example PLINQ takes your data query and, like a team of clones, processes different parts of the data at the same time. It’s like having multiple shoppers in the store, each with a copy of the shopping list, working in parallel to finish the shopping faster. using System; using System.Linq; using System.Threading; using System.Threading.Tasks; class PLINQMethodsExample { static void Main(string[] args) { // Example data source var numbers = Enumerable.Range(1, 100); // AsParallel to enable parallelization var parallelQuery = numbers.AsParallel(); // WithDegreeOfParallelism to limit the number of processors to use var limitedParallelismQuery = numbers.AsParallel().WithDegreeOfParallelism(2); // WithExecutionMode to hint PLINQ on how to execute the query var forcedParallelismQuery = numbers.AsParallel().WithExecutionMo...