Last active
April 7, 2020 16:02
-
-
Save grishace/551120506d2b5937f48c38ac150b696a to your computer and use it in GitHub Desktop.
Sequential asyncs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open FSharp.Control | |
[<EntryPoint>] | |
let main _ = | |
let rnd = Random() | |
let workflows = | |
[| | |
for x in 1 .. 100 -> | |
async { | |
do! Async.Sleep (rnd.Next(10) * 100) | |
printfn "Computing %d" x; return x | |
} | |
|] | |
let x = | |
workflows | |
|> AsyncSeq.ofSeq | |
|> AsyncSeq.mapAsync id | |
|> AsyncSeq.toArrayAsync | |
|> Async.RunSynchronously | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment