I am experimenting with parallel programming. I have a normal loop:
for (int i = 0; i < 100000; i++)
{
Console.WriteLine("Thread ID: {0} and i is " + i + " Time Elapsed: " + sw.Elapsed,
Thread.CurrentThread.ManagedThreadId);
}
This loops just increments numbers to 100000
Can I use this for
loop and turn it into a Parallel.For
loop to count numbers to 100000 but using all CPUs in parallel?
Also, when using a Parallel.For
, what are the parameters needed? How would you use it in a very basic way?