Reputation: 16056
I think async/await keywords here are redundant.
Parallel.Invoke(
async () => await DoSomethingAsync(1).ConfigureAwait(false),
async () => await DoSomethingAsync(2).ConfigureAwait(false)
);
Given a number of task-returning methods, is there any more straightforward way to run them in parallel and return when all are complete?
Upvotes: 5
Views: 556
Reputation: 8325
await Task.WhenAll(DoSomethingAsync(1), DoSomethingAsync(2));
Optionally add .ConfigureAwait(false)
to the WhenAll()
, depending on context.
Upvotes: 4