Is it possible to simplify this parallel asynchronous call?

I think the async / wait keywords are redundant here.

Parallel.Invoke( async () => await DoSomethingAsync(1).ConfigureAwait(false), async () => await DoSomethingAsync(2).ConfigureAwait(false) ); 

Given a number of task return methods, is there an easier way to run them in parallel and return when they are all completed?

+5
source share
1 answer
 await Task.WhenAll(DoSomethingAsync(1), DoSomethingAsync(2)); 

If necessary, add .ConfigureAwait(false) to WhenAll() , depending on the context.

+4
source

Source: https://habr.com/ru/post/1260677/


All Articles