I have the following code inside a bigger loop, after profiling my code I discovered that all the Parallel.For gain in execution speed is lost in the long time the Stop()
method takes to complete. Is there any way to improve this? Maybe calling Thread.Sleep()
?
Thanks.
Parallel.For(0, 1000, (i, loopState) =>
{
if (a == b)
loopState.Stop();
});