Skip to content

Instantly share code, notes, and snippets.

@akovbovich
Created January 20, 2012 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akovbovich/1644771 to your computer and use it in GitHub Desktop.
Save akovbovich/1644771 to your computer and use it in GitHub Desktop.
open System.IO
open System.Net
let AsyncHttp(url:string) =
async { // Create the web request object
let req = WebRequest.Create(url)
// Get the response, asynchronously
let! rsp = req.GetResponseAsync()
// Grab the response stream and a reader. Clean up when we're done
use stream = rsp.GetResponseStream()
use reader = new System.IO.StreamReader(stream)
// synchronous read-to-end
return reader.ReadToEnd() }
Async.Run
(Async.Parallel [ AsyncHttp "http://www.live.com";
AsyncHttp "http://www.google.com";
AsyncHttp "http://maps.live.com";
AsyncHttp "http://maps.google.com"; ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment