Simulating an Intensive Work

Parallel LINQ provides benefits when you work in extreme situations such as intensive works or large amounts of data. In different situations PLINQ is not necessarily better than classic LINQ. To understand how PLINQ works, first we need to write code that simulates an intensive work. After creating a new Console project, write the following method that simply determines if a number is odd but suspending the current thread for a big number of milliseconds invoking the System.Threading.Thread.SpinWait shared method:

image

Now that we have an intensive work, we can compare both classic and parallel LINQ queries.

Get Visual Basic® 2010 Unleashed 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.