Is there an equivalent to 'continue' in a Parallel.ForEach?

John Egbert picture John Egbert · Sep 22, 2010 · Viewed 58.2k times · Source

I am porting some code to Parallel.ForEach and got an 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;
});

Answer

dave picture dave · Sep 22, 2010
return;

(the body is just a function called for each item)