continue is not working in Parallel.Foreach method

Viewed 113

I was using foreah loop for some conditions and now I need to use Parallel.Foreach loop for perrformance improvement.I have list of data in studentdetails which is coming from mongo db collectio .Using foreach loop consumes lot of time to return final data based on some logic. I am not doing any transactional operations in code. Below are the samples of my code;

       **Code**

    **var studentdetails = await _mongoRepo.GetAsync(filter,projection,StudentCollection);
   
    foreach (var student in studentdetails)
    
         if (getsection.studenttab =null)
    {
        _logger.log("something");

    continue;
    }
    
    some other busiess logic
    }
   return abc;**
    
    After using Parallel.Foreach 
    *****************************
    
    **Parallel.Foreach(studentdetails , resource =>
    {
         if (getsection.studenttab =null)
    {
        _logger.log("something");

         continue;
    }
    
    some other busiess logic
    
    });
return abc;
        
   

But I am getting this error: no enclosing loop out of which is break or continue. and Metadata projectname.dll could not be found What should I do here?

1 Answers
Related