Tasktask = Task.Run(() => { // code to execute asynchronously return 42; });
int result = await task;
TaskThis creates three parallel tasks and waits for all three to complete before moving on. Package library: System.Threading.Taskstask1 = Task.Run(() => { /* code */ }); Task task2 = Task.Run(() => { /* code */ }); Task task3 = Task.Run(() => { /* code */ }); await Task.WhenAll(task1, task2, task3);