I\'m trying to make an asynchronous HTTP GET request using Webclient, however, the registered callback never gets called. I\'ve also tried with the sync one, and it worked fine.
Maybe because you disposing the WebClient
before it finished downloading. The code execution don't stop on asyncWebRequest.DownloadStringAsync(url);
and you are disposing the WebClient
object by closing the using statement.
try to dispose the WebClient
on asyncWebRequest_DownloadStringCompleted
.
results
The simpliest solution is to add Console.ReadKey()
at the end of AsyncWebRequest(url)
method. This way asyncWebRequest.DownloadStringAsync(url)
will be able to retrieve data.