Skip to content

Instantly share code, notes, and snippets.

@peteraritchie
Created May 1, 2012 02:31
Show Gist options
  • Save peteraritchie/2564547 to your computer and use it in GitHub Desktop.
Save peteraritchie/2564547 to your computer and use it in GitHub Desktop.
async GetResponse C# 5
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com/en/us/default.aspx");
HttpWebResponse webResponse = (HttpWebResponse)await webRequest.GetResponseAsync();
Trace.WriteLine(webResponse.StatusCode);
webRequest = (HttpWebRequest)WebRequest.Create("http://google.ca");
webResponse = (HttpWebResponse)await webRequest.GetResponseAsync();
Trace.WriteLine(webResponse.StatusCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment