using System.Runtime.CompilerServices; using System.Threading.Tasks; // Example 4: await IEnumerable> // Just a dummy async function public static Task GetSomethingAsync(int number) => Task.FromResult($"Something {number}"); // This extension method allows us to await many tasks public static TaskAwaiter GetAwaiter(this IEnumerable> manyTasks) => Task.WhenAll(manyTasks).GetAwaiter(); // this line will now compile and run var manyThings = await Enumerable.Range(0, 10).Select(GetSomethingAsync); // Just to prove it, output all the things foreach(var thing in manyThings) { Console.WriteLine(thing); }