I'm trying to do something like this:
foreach (var o in ObjectList)
{
CalculateIfNeedToMakeTaskForO(o);
if (yes)
TaskList.Add(OTaskAsync());
}
Now I would like to wait for all these tasks to complete.
Besides doing
foreach(var o in ObjectList)
{
Result.Add("result for O is: "+await OTaskAsync());
}
Is there anything I could do? (better, more elegant, more "correct")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…