November 2017
Intermediate to advanced
800 pages
30h 51m
English
Add a new console application project named NestedAndChildTasks.
In Visual Studio 2017, in the solution's Properties, remember to change Startup Project to Current selection.
Ensure the following namespaces have been imported:
using System; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; using static System.Console;
Inside the Main method, add the following statements:
var outer = Task.Factory.StartNew(() => { WriteLine("Outer task starting..."); var inner = Task.Factory.StartNew(() => { WriteLine("Inner task starting..."); Thread.Sleep(2000); WriteLine("Inner task finished."); }); }); outer.Wait(); WriteLine("Outer task finished."); WriteLine("Press ENTER to end."); ReadLine(); ...Read now
Unlock full access