<Query Kind="Program">
  <Namespace>System.Threading.Tasks</Namespace>
</Query>

int tid () { return Thread.CurrentThread.ManagedThreadId; }

async Task fun3() {
    Console.WriteLine("[{0}] ... 3.1", tid());
    await Task.Delay(1000);
    Console.WriteLine("[{0}] ... 3.2", tid());
}

async Task fun2() {
    Console.WriteLine("[{0}] ... 2.1", tid());
    await fun3();
    Console.WriteLine("[{0}] ... 2.2", tid());
    await fun3();
    Console.WriteLine("[{0}] ... 2.3", tid());
}

async Task fun1() {
    Console.WriteLine("[{0}] ... 1.1", tid());
    await fun2();
    Console.WriteLine("[{0}] ... 1.2", tid());
}
    
void Main() {
    Console.WriteLine("[{0}] ... 0.1", tid());
    fun1().Wait();  
	// Task.Run(() => fun1()).Wait();
    Console.WriteLine("[{0}] ... 0.2", tid());
}