且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何等待异步完成

更新时间:2022-06-23 22:21:10

好回答我的问题似乎有点扯,但这个似乎工作。有人拿出更好的东西,所以我可以奖励他们的答案:)

Well answering my own question seems lame, but this seems to work. Someone come up with something better so I can award them the answer :)

let dowork n =
    async {
        do printfn "work %d" n
    }

let creatework() =
    [1..5] |> Seq.map dowork |> Async.Parallel |> Async.RunSynchronously

creatework()    
printfn "finished"

它给出​​了不同的输出,但拍完到目前为止总是在最后...

It gives various output, but "finished" so far is always last...