Created
January 20, 2012 03:24
-
-
Save akovbovich/1644771 to your computer and use it in GitHub Desktop.
This file contains 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 | |
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