Skip to main content

Command Palette

Search for a command to run...

How to wait on two tasks?

Published
•1 min read•View as Markdown

Suppose there are two async function GetX and GetY, then the code to get them to run in parallel and wait is.

var tx = GetX();
 var ty = GetY();
 var results = await Task.WhenAll(tx,ty);
 var z = results[0] + results[1];

The type for the function is

async Task GetX();