PLINQ
PLINQ (Parallel LINQ, pronounced “plink”) allows a program to execute LINQ queries across multiple processors or cores in a multi-core system. If you have a multi-core CPU and a nicely parallelizable query, PLINQ may improve your performance considerably.
So what kinds of queries are “nicely parallelizable”? The short, glib answer is, it doesn’t really matter. Microsoft has gone to great lengths to minimize the overhead of PLINQ, so using PLINQ may help for some queries and shouldn’t hurt you too much for queries that don’t parallelize nicely.
Simple queries that select items from a data source often work well. If the items in the source can be examined, selected, and otherwise processed independently, then the query is parallelizable.
Queries that must use multiple items at the same time do not parallelize nicely. For example, adding an OrderBy function to the query forces the program to gather all of the results before sorting them so that part of the query at least will not benefit from PLINQ.
Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.