Running tasks asynchronously

First, we will write a simple console application that needs to execute three actions.

Running multiple actions synchronously

Start Microsoft Visual Studio 2015. In Visual Studio, press Ctrl + Shift + N or go to File | New | Project….

In the New Project dialog, in the Installed Templates list, select Visual C#. In the center list, select Console Application, type the name as Ch12_Tasks, change the location to C:\Code, type the solution name as Chapter12, and then click on OK.

Ensure that the following namespaces have been imported:

using System;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using static System.Console;

In the Program class, add the following code. There are three methods ...

Get C# 6 and .NET Core 1.0: Modern Cross-Platform Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.