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

let tid () = Thread.CurrentThread.ManagedThreadId

let fun3 = async {
    printfn "[%d] ... 3.1" (tid())
    do! Async.Sleep 1000
    printfn "[%d] ... 3.2" (tid())
}

let fun2 = async {
    printfn "[%d] ... 2.1" (tid())
    do! fun3
    printfn "[%d] ... 2.2" (tid())
    do! fun3
    printfn "[%d] ... 2.3" (tid())
}

let fun1 = async {
    printfn "[%d] ... 1.1" (tid())
    do! fun2
    printfn "[%d] ... 1.2" (tid())
}

printfn "[%d] ... 0.1" (tid())
do Async.RunSynchronously fun1
printfn "[%d] ... 0.2" (tid())

//
