Skip to content

Instantly share code, notes, and snippets.

@VelizarHristov
Last active February 13, 2017 15:04
Show Gist options
  • Save VelizarHristov/9431523e684405a511ca2a2caf062757 to your computer and use it in GitHub Desktop.
Save VelizarHristov/9431523e684405a511ca2a2caf062757 to your computer and use it in GitHub Desktop.
let retrieveNumber = async {
do! Async.Sleep 4000
return 0
};;
let anotherJob = async {
do! Async.Sleep 500
};;
// start retrieving number;
// do anotherJob meanwhile (in parallel);
// return the number.
let doWork =
let numberPromise = retrieveNumber |> Async.StartAsTask
anotherJob |> Async.RunSynchronously
numberPromise |> Async.AwaitTask |> Async.RunSynchronously;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment