In my view the most realistic scenario is when tasks have a heavy operation to complete. Shivprasad's approach focuses more on object creation/memory allocation than on computing itself. I made a research calling the following method:
public static double SumRootN(int root)
{
double result = 0;
for (int i = 1; i < 10000000; i++)
{
result += Math.Exp(Math.Log(i) / root);
}
return result;
}
Execution of this method takes about 0.5sec.
I called it 200 times using Parallel:
Parallel.For(0, 200, (int i) =>
{
SumRootN(10);
});
Then I called it 200 times using the old-fashioned way:
List<Task> tasks = new List<Task>() ;
for (int i = 0; i < loopCounter; i++)
{
Task t = new Task(() => SumRootN(10));
t.Start();
tasks.Add(t);
}
Task.WaitAll(tasks.ToArray());
First case completed in 26656ms, the second in 24478ms. I repeated it many times. Everytime the second approach is marginaly faster.