1async function printFiles () {
2 const files = await getFilePaths();
3
4 await Promise.all(files.map(async (file) => {
5 const contents = await fs.readFile(file, 'utf8')
6 console.log(contents)
7 }));
8}
1 for (const file of files) {
2 const contents = await fs.readFile(file, 'utf8');
3 console.log(contents);
4 }
5
1public async Task RunAsync()
2{
3 var tasks = new List<Task>();
4
5 foreach (var x in new[] { 1, 2, 3 })
6 {
7 var task = DoSomethingAsync(x);
8 tasks.Add(task);
9 }
10
11 await Task.WhenAll();
12}
13