the program i'm currently creating has some pictureboxes. The images from these are not added to the resources, instead i want to load them from a website. Its working fine so far, the biggest problem is that the program crashes if it could not load the images. I searched for this problem and it seems that getting the images async would be the right way to solve this problem.
Currently this is the way i'm loading the images:
private static Image GetImageFromURL(string url)
{
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream stream = httpWebReponse.GetResponseStream();
return Image.FromStream(stream);
}
....
foo.Image = GetImageFromURL("https://foo.com/bar.jpg");
I've read many threads on SO and other sites but i still dont understand async. I realy hope someone here can try to explain how to use it if async is the right way to go.
Sorry for my bad english, i hope its not to hard to understand.