Asynchronous Workflows

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
let runProcess i =
  async {
    let delay = System.Random().Next(500)
    // let! or use! for asynchronous equivalents of let or use
    // can be used here when results are needed
    do! Async.Sleep delay
    printfn "Done processing %d after %dms" i delay
  }

[1; 2; 3]
|> Seq.map runProcess
|> Async.Parallel
|> Async.RunSynchronously

printfn "Done."