I find it difficult to understand loopState.Stop() and loopState.Break() . I read MSDN and a few posts about this, but I'm still confused.
As far as I understand, each iteration separator provides the remaining indices for thread processing, and loopState.Stop() stops all threads, and loopState.Break() stops the current thread.
However, let's look at the following situation:
Parallel.For(0, 100, (i, loopState) => { if (i >= 10) loopState.Break(); Debug.Write(i); });
For this loop, I have the following result:
0 25 1 2 3 4 5 6 7 8 9 10
I have no idea why the result is 10 and 25 numbers.
Can anybody help?
Postscript I have i5 520M CPU (2 cores => 4 threads)
Michał Jankowski
source share