private async void btnTest_Click(object sender, EventArgs e)
{
List<Task> lstTasks = new List<Task>();
foreach (int val in lstItems)
{
lstTasks.Add(MyAsyncMtd(val));
}
await Task.WhenAll(lstTasks);
...
}
private async Task MyAsyncMtd(int val)
{
...
await Task.Delay(1000);
...
}
Question: On button click, at the 1st iteration of the for loop, when the await keyword in the MyAsyncMtd
is encountered, then I know that the control goes to the caller. The caller in this case is the button click method. Does this mean that the next iteration gets processed while waiting (Task.Delay) on the 1st iteration's Task.Delay (in other words - does await return Task to the caller?)? or what happens exactly?