An attempt to implement downloadStringAsync()to prevent the user interface from freezing for 10 seconds when loading one byte of data. However, although the download is complete, it freezes the user interface just as if I were using it downloadString().
Here is my code:
public void loadHTML()
{
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(loadHTMLCallback);
client.DownloadStringAsync(new Uri("http://www.example.com"));
return;
}
public void loadHTMLCallback(Object sender, DownloadStringCompletedEventArgs e)
{
if (!e.Cancelled && e.Error == null)
{
string result = (string)e.Result;
}
}
source
share