Keeping the counter, not looking at the index? For instance:
int counter = 0;
Parallel.For(4, 500, i => {
int progress = Interlocked.Increment(ref counter);
Console.WriteLine("{0}: {1}", progress, i);
});
(use Interlockedis important to avoid getting race conditions when accessing counter)
source
share