Skip to content

Instantly share code, notes, and snippets.

@altbodhi
Created September 21, 2018 09:19
Show Gist options
  • Save altbodhi/35356b14101736cc33f65d1ed2107254 to your computer and use it in GitHub Desktop.
Save altbodhi/35356b14101736cc33f65d1ed2107254 to your computer and use it in GitHub Desktop.
Test work IProgress interface in fs
open System.IO
open System.Net
open System.Text
open System
let httpAsync (progress : IProgress<string>) (url : string) = async {
let req = System.Net.WebRequest.Create(url)
use! resp = req.AsyncGetResponse()
progress.Report(sprintf "%s AsyncGetResponse" url)
use stream = resp.GetResponseStream()
use reader = new StreamReader(stream, Encoding.GetEncoding(1251))
return! reader.ReadToEndAsync() |> Async.AwaitTask }
let println = printfn "%s"
let progress = new Progress<string>(fun s -> println s)
(progress :> IProgress<string>).Report("test") //не работает
println "line" // работает
//let httpProgress = httpAsync (progress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment