Search code examples
c#foreachparallel-processingtask-parallel-libraryparallel.foreach

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


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;
});

Solution

  • return;
    

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