我觉得你有点迷路了。Async.StartAsTask
其次是Async.AwaitTask
有效地相互抵消,其副作用Task
是在进程中创建的实际上触发blockingFoo
了线程池中包含的异步块的评估。因此,它起作用了,但是却超出了期望。
如果asyncFoo
要从另一个异步块中触发对它的评估,则更自然的方法是在Async.Start
不想等待完成时使用它,或者Async.StartChild
如果您愿意,则使用它。
let asyncFoo = async { blockingFoo() |> ignore } async { // "fire and forget" asyncFoo |> Async.Start // trigger the computation let! comp = Async.StartChild asyncFoo // do other work here while comp is executing // await the results of comp do! comp }