I have a scenario where I have to run list of students in parallel/independently once I get list of students. However when I run those with following kinda code, program ends without completing properly.
public async Task ProcessStudents()
{
var students = await GetStudentsAsync().ConfigureAwait(false);
ProcessSingleStudent(students);
}
private static ProcessSingleStudent(IEnumerable<StudentModel> students)
{
students.ForEach(async student =>
{
await ValidateSingleStudentAsync(student).ConfigureAwait(false);
}
}
private async Task ValidateSingleStudentAsync(StudentModel student)
{
//Do some validations here
if(validate)
{
var updated = await UpdateStudentAsync(student).configureAwait(false); //<== This cause issue
}
}
As I see UpdateStudentAsync
causing issue, that if go with F10
this method doesn't return anything and console app stops. Even I put every call in try-catch
I couldn't find anything. If I step in each debug point, I get expected result.
Unable to understand where is the issue.