Is there an equivalent to 'continue' in a Parallel.ForEach?
I am porting some code to Parallel.ForEach and got a开发者_开发百科n error with a continue I have in the code. Is there something equivalent I can use in a Parallel.ForEach functionally equivalent to continue in a foreach loop?
Parallel.ForEach(items, parallelOptions, item =>
{
if (!isTrue)
continue;
});
return;
(the body is just a function called for each item)
When you converted your loop into a compatible definition for the Parallel.Foreach logic, you ended up making the statement body a lambda. Well, that is an action that gets called by the Parallel function.
So, replace continue with return, and break with Stop() or Break() statements.
加载中,请稍侯......
精彩评论