using System.Threading.Tasks;
public static async Task Main()
Task processLoadPartyTask = Task.WhenAll(Enumerable.Range(1, 10).Select(GetAndInsertLoadParties));
foreach (int shipmentId in Enumerable.Range(1000, 10))
await UpsertShipmentAsync(shipmentId).ConfigureAwait(false);
await processLoadPartyTask.ConfigureAwait(false);
private static async Task UpsertShipmentAsync(int shipmentId)
Console.WriteLine($"UpsertShipment {shipmentId} Started");
await Task.Delay(TimeSpan.FromMilliseconds(600)).ConfigureAwait(false);
Console.WriteLine($"UpsertShipment {shipmentId} Completed");
private static async Task GetAndInsertLoadParties(int partyId)
Console.WriteLine($"GetAndInsertLoadParties {partyId} Started");
await Task.Delay(TimeSpan.FromSeconds(partyId)).ConfigureAwait(false);
Console.WriteLine($"GetAndInsertLoadParties {partyId} Completed");