Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
type BusyBuilder(blockUi, unblockUi) =
member this.Bind(x, f) = async.Bind(x, f)
member this.Combine(e1, e2) = async.Combine(e1, e2)
member this.Delay(f) =
async {
blockUi ()
let! result = async.Delay f
unblockUi ()
return result
member this.For(coll, f) = async.For(coll, f)
member this.Return(x) = async.Return(x)
member this.ReturnFrom(m) = async.ReturnFrom(m)
member this.TryWith(expr, handler) = async.TryWith(expr, handler)
member this.TryFinally(expr, compensation) = async.TryFinally(expr, compensation)
member this.Using(resource, binder) = async.Using(resource, binder)
member this.While(guard, computation) = async.While(guard, computation)
member this.Zero() = async.Zero()
let busy = new BusyBuilder((fun () -> printfn "blocking UI"), (fun () -> printfn "unblocking UI"))
busy {
let uri = new System.Uri("")
let webClient = new System.Net.WebClient()
let! html = webClient.AsyncDownloadString(uri)
printfn "%s" html
return html
} |> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment