Parallel.For and Break() misunderstanding?
问题 I'm investigating the Parallelism Break in a For loop. After reading this and this I still have a question: I'd expect this code : Parallel.For(0, 10, (i,state) => { Console.WriteLine(i); if (i == 5) state.Break(); } To yield at most 6 numbers (0..6). not only he is not doing it but have different result length : 02351486 013542 0135642 Very annoying. (where the hell is Break() {after 5} here ??) So I looked at msdn Break may be used to communicate to the loop that no other iterations after