Created
September 21, 2018 09:19
-
-
Save altbodhi/35356b14101736cc33f65d1ed2107254 to your computer and use it in GitHub Desktop.
Test work IProgress interface in fs
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.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