WebClient.DownloadStringTaskAsync problem

The following piece of code works fine (prints the markup on the console):

System.Net.WebClient wc = new System.Net.WebClient(); var task1 = wc.DownloadStringTaskAsync("http://ift.tt/1YwtB4M;); Console.WriteLine(task1.Result); 

But when I await the task it just awaits forever and the task's state is WaitingForActivation:

 System.Net.WebClient wc = new System.Net.WebClient(); var task1 = wc.DownloadStringTaskAsync("http://ift.tt/1YwtB4M;); Console.WriteLine(await task1); Console.WriteLine("done!"); // this never gets printed 

What am I missing?

by SevenOctillianAtoms via /r/csharp

Leave a Reply