Answers for "C# foreach loop async but wait at end"

C#
0

C# foreach loop async but wait at end

public async Task RunAsync()
{
    var tasks = new List<Task>();
 
    foreach (var x in new[] { 1, 2, 3 })
    {
        var task = DoSomethingAsync(x);
        tasks.Add(task);
    }
 
    await Task.WhenAll();
}
Posted by: Guest on April-27-2020

C# Answers by Framework

Browse Popular Code Answers by Language