Thursday, May 22, 2014

C# Async HttpWebRequest Console POC

So I have to connect to an API and get some JSON.  I researched the WebRequest class.  I found that there is an option in .NET to use Async programming with this class.  So I did some research to find out that there are many ways to do the async.  The easiest is using the new keywords async and await.  See Asynchronous Programming with Async and Await (C# and Visual Basic).  

There is a full working example in the doc for GetResponse Method which is not async.

This is the working Proof of Concept (POC) that I came up with.