I'm playing around with some of the Async work flows from the Real World Functional Programming book and although they work fine with FSI 1.9.6.2 on .NET 2.0 I'm struggling to get it to work on FSI 1.9.6.16 on .NET 4.0
This is the code:
open System.IO
open System.Net
open Microsoft.FSharp.Control
let downloadUrl(url:string) = async {
let req = HttpWebRequest.Create(url)
let! resp = req.AsyncGetResponse()
let stream = resp.GetResponseStream()
use reader = new StreamReader(stream)
return! reader.AsyncReadToEnd() }
let downloadTask = downloadUrl("http://www.manning.com");;
And then to run it on .NET 2.0 I use
Async.Run(downloadTask, 10000);;
And for .NET 4.0
Async.RunSynchronously(downloadTask, 10000);;
The former works fine and it prints the Manning website page to the screen but the later times out.
Any ideas?
Cheers,
Mark
Mark Needham
Application Developer, ThoughtWorks
http://www.markhneedham.com/blog