c# - Running several methods in a WaitAll -


i have several methods database access tools.

await task.waitall() {   one();   two();   three();  } 

none of methods async, how wrap them in task can await them , have them run in own task?

put each method in task.run:

list<task> alltasks = new list<task>() {    task.run(new action(one)),    task.run(new action(two)),    task.run(new action(three)), }; await task.whenall(alltasks); 

note awaitable version of method whenall not waitall (which blocks synchronously).

of course, lot simpler if methods return task objects.


Comments