Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Last active January 11, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacabraham/354d407e5613c39606edf8418c4931e9 to your computer and use it in GitHub Desktop.
Save isaacabraham/354d407e5613c39606edf8418c4931e9 to your computer and use it in GitHub Desktop.
let x =
[| 1 .. 10 |]
|> Array.map(fun n -> async {
printfn "Starting %d" n
do! Async.Sleep 1000
printfn "Done %d" n
return n * 1000
})
let x2 = Async.Parallel(x, 1) |> Async.RunSynchronously
let x3 = x |> Async.Sequential |> Async.RunSynchronously
(* both output:
Starting 1
Starting 2
Starting 3
Starting 4
Starting 5
Starting 6
Starting 7
Starting 8
Starting 9
Starting 10
Done 10
Done 2
Done 1
Done 5
Done 7
Done 3
Done 8
Done 6
Done 9
Done 4
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment