Getting ready

We will start off by looking at where the parallel foreach loop does not perform better than the standard foreach loop. For this, we will create a small list of 500 items and just iterate over the list, writing the items to the console window.

For the second example, which illustrates the power of the parallel foreach loop, we will use the same list and create a file for each item in the list. The power and benefit of the parallel foreach loop will be evident in the second example. You will need to add the using System.Diagnostics; and using System.IO; namespaces to run this recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.153.212