Today I was wondering how to transform a list of Tasks by awaiting each of it. Consider the following example:
private static void Main(string[] args) {
What about this:
await Task.WhenAll(tasks1); var gainStrings = tasks1.Select(t => t.Result).ToList();
Wait for all tasks to end and then extract results. This is ideal if you don't care in which order they are finished.
EDIT2: Even better way:
var gainStrings = await Task.WhenAll(tasks1);