1

I'm trying to figure out the amount of HTTP requests that my application perform when using a regular for loop with a method that performs the request vs PLINQ or using the "regular" parallel for loop. So for example, lets imagine we have a method called DoRequest() which performs 1 http request at a time when called.

When using it with regular for loop:

for(int i=0; i<100;i++){
DoRequest();
}

With Parallel for loop:

Parallel.For(0,100,i=> DoRequest());

And with PLINQ:

MyList.AsParallel().WithDegreeOfParallelism(18).ForAll(i=>DoRequest());

With the regular for loop, I'm guessing that my application does 1 request at a time, the counter will move forward when the first call is done?

The question that I have here is, how many requests is my application doing in 2nd and 3rd case??

I'm shooting in dark but I'll say that with 3rd method it does 18 parallel requests at a time if I'm correct?

What is the logic behind it ?

User987
  • 3,663
  • 15
  • 54
  • 115
  • Take a look at this post http://stackoverflow.com/a/1114402/3877877 ... this one https://msdn.microsoft.com/en-us/library/system.threading.tasks.paralleloptions.maxdegreeofparallelism.aspx. Perhaps it can answer the question of the 2nd method – Martin E Jan 13 '17 at 20:54

0 Answers0