Parallel ForEach Loop

added by rcash
8/21/2011 6:38:44 PM

248 Views

The parallel ForEach loop iterates through a collection of items, executing the same code for each item with the potential for the data to be decomposed and processed in parallel. This article examines the process and provides examples.


2 comments

vijayst
8/21/2011 10:43:36 PM
Parallel foreach loop internally should create multiple threads. Are there any restrictions where it can be used? Can this be used in a server framework like ASP.NET. My understanding of ASP.NET threads is that it has a threadpool of which only one thread goes in processing a request. To create background threads within the ASP.NET framework, some special semantics are required. I will be curious to know if the Parallel foreach loop will work within the ASP.NET framework.

dpeterson
8/23/2011 8:55:42 AM
I believe that the parallel for/foreach loops will work on ASP.NET. My guess is that whatever special work is required to spin up a new thread under the worker pool, it handles automatically.