Created
April 17, 2020 13:14
-
-
Save natalie-o-perret/3e0ceea01a994531914e5260f1521f95 to your computer and use it in GitHub Desktop.
Hot / Cold asynchrony
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
open System.Threading.Tasks | |
open FSharp.Control.Tasks.V2.ContextInsensitive | |
let aTask = task { | |
do! Task.Delay(1000) | |
printfn "I'm in aTask" | |
} | |
let anAsync = async { | |
do! Task.Delay(1000) |> Async.AwaitTask | |
printfn "I'm in anAsync" | |
} | |
let runTaskSync t = | |
t |> Async.AwaitTask |> Async.RunSynchronously | |
let runAsyncSync a = | |
a |> Async.RunSynchronously | |
[<EntryPoint>] | |
let main _ = | |
runTaskSync aTask | |
runTaskSync aTask | |
runAsyncSync anAsync | |
runAsyncSync anAsync | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment