Stop vs Break in Parallel.For

loopState.Break() does not break the function like a return. So the line after the loopState.Break() will still be executed. After that scope has ended for that number, for checks if the loopState.Break() had been called. If so, all loops are allowed to continue until the number has been reached that called Break.

In your example, the loops with 0 till 24 will break at the same time as the loop 25 till 49 (and display their "breaking" numbers).

Loop 50..74 and 75..99 will not even get started because the second loop 25..49 has already aborted the whole for-operation, since their staring numbers are greater then the breaking number 10.


From the documentation of Break():

Break may be used to communicate to the loop that no other iterations after the current iteration need be run. For example, if Break is called from the 100th iteration of a for loop iterating in parallel from 0 to 1000, all iterations less than 100 should still be run, but the iterations from 101 through to 1000 are not necessary.

What this means is that the current iteration will still finish (so 10 gets printed). Break() also isn't capable of time travel, so the 25 will stay printed. What Break() means is that no new iterations beyond 10 will be started.