- var items = Enumerable.Range(0, 20);
- int cnt = 0;
- Parallel.For(0, items.Count(), (int i) => {
- WorkOnItem(items.ToArray()[i]);
- cnt++;
- });
- static void WorkOnItem(object item)
- {
- Console.WriteLine("Working on item:" + item);
- Thread.Sleep(10);
- }Does it mean the thread failed?
Why does counting is not consistent in Parallel.For?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Anoop Kumar SharmaRank #127 · 17.4K reputationPosted Dec 23, 2018, 1:35 AM EST