I want to do a Parallel.ForEach(... ) for the below code snipet, however as there are two function calls - both should happend in the same block, as the second funtion is consuming the value returned by the first function. I don't know who to achive this. Basically I want to convert the below into a Parallel.ForEach(...). Thanks in advance.
List<Employee> employeeList = GetEmployees();
foreach (var emp in employeeList)
{
var empDetails = GetEmpDetails(emp.EmployeeId);
ProcessEmployeeDetails(empDetails);
}
I already tried the below, it is not working:
Parallel.ForEach(employeeList, emp =>
{
var empDetails = GetEmpDetails(emp.EmployeeId);
ProcessEmployeeDetails(empDetails);
});