I have a function that loads an image from the internet. Yet, while it is loading, my application can't do anything else. Is there a way around this?
Thanks!
Here is my code:
public static Bitmap BitmapFromWeb(string URL)
{
try
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
myRequest.Method = "GET";
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Bitmap bmp = new Bitmap(myResponse.GetResponseStream());
myResponse.Close();
return bmp;
}
catch (Exception ex)
{
return null;
}
}
private void button1_Click(object sender, EventArgs e)
{
load_avatrar();
}
private void load_avatrar()
{
pictureBox_avatar.Image = BitmapFromWeb(avatral_url);
}