Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| // <Snippet1> | |
| using System; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| public class Example | |
| { | |
| public static void Main() | |
| { | |
| var parent = Task.Factory.StartNew(() => { | |
| Console.WriteLine("Outer task executing."); | |
| var child = Task.Factory.StartNew(() => { | |
| Console.WriteLine("Nested task starting."); | |
| Thread.SpinWait(500000); | |
| Console.WriteLine("Nested task completing."); | |
| }); | |
| }); | |
| parent.Wait(); | |
| Console.WriteLine("Outer has completed."); | |
| } | |
| } | |
| // The example produces output like the following: | |
| // Outer task executing. | |
| // Nested task starting. | |
| // Outer has completed. | |
| // Nested task completing. | |
| // </Snippet1> | |