static async Task Main()
{
var f = async (char c) =>
{
for (int i = 0; i < 5; ++i)
{
Console.WriteLine(c);
await Task.Yield();
}
};
Console.WriteLine("Begin");
var a = f('*');
var b = f('-');
await Task.WhenAll(a, b);
Console.WriteLine("End");
}
and
async function Main() {
let f = async (c) => {
for (let i = 0; i < 5; ++i) {
console.log(c)
await Promise.resolve();
}
}
console.log('Begin');
const a = f('*');
const b = f('-');
await Promise.all([a, b]);
console.log('End');
}