Running tasks asynchronously
First, we will write a simple console application that needs to execute three methods, and execute them synchronously (one after the other).
Running multiple actions synchronously
In Visual Studio 2017, press Ctrl + Shift + N or go to File | New | Project....
In the New
Project dialog, in the Installed | Templates list, expand Visual C#, and select .NET Core. In the center list, select Console App (.NET Core), type the name as Ch12_Tasks
, change the location to C:\Code
, type the solution name as Chapter12
, and then click on OK.
In Visual Studio Code, create a directory named Chapter12
with a subfolder named Ch12_Tasks
, and open the Ch12_Tasks
folder. In the Integrated Terminal, execute the command: dotnet new console
.
In both Visual Studio 2017 and Visual Studio Code, ensure that the following namespaces have been imported:
using System; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; using static System...