How to wait on two tasks?


1 min read

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();