using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TaskDemo
{
class Program
{
static void Main(string[] args)
{
ParentAndChild();
Console.Read();
}
static void ParentAndChild()
{
var parent = new Task(TaskParent);
parent.Start();
System.Threading.Thread.Sleep(2000);
Console.WriteLine(parent.Status);
System.Threading.Thread.Sleep(4000);
Console.WriteLine(parent.Status);
}
static void TaskParent()
{
Console.WriteLine("task id {0}",Task.CurrentId);
var child = new Task(TaskChild);
child.Start();
System.Threading.Thread.Sleep(4000);
Console.WriteLine("Parent started child");
}
static void TaskChild()
{
Console.WriteLine("child");
System.Threading.Thread.Sleep(5000);
Console.WriteLine("child finished");
}
}
}