I'm using 2 WebClients in my app, for 2 different weather API's.
When my internet connection is slow I get an exception from one of the API's.. It returns a 404 Notfound error.
I have tested this by disabling my WiFi, and put the data connection to '2G'. The first API returns the data with no problem, the second API however crashes my app with a WebException.
When I turn on the WiFi again it works flawlessly. Looks like the second API has a very little patience with slow connections.
Is there a way to fix this? I have also tried to change the WebClient into a HttpWebRequest but the problem still occurs.
Kind regards, Niels
EDIT My code:
private void GettingTheData()
{
WebClient Client = new WebClient();
Client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Client _DownloadStringCompleted);
Client.DownloadStringAsync(new Uri("http://theURI.com"));
}
void Client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string result = e.Result.ToString();
// Let's do the cool stuff overhere
}