Last active
February 13, 2017 15:04
-
-
Save VelizarHristov/9431523e684405a511ca2a2caf062757 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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