exit the loop in javascript from async call code example
Example: 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();
}