Hey guys,
I have a program that downloads a picture from a website and stores it as a stream.
CSharp Code:
public void UpdateGGImagesManager(int GateID, PictureBox pbox) { Thread a = new Thread(() => UpdateGGImages(GateID, pbox)); a.IsBackground = true; a.Start(); } public void UpdateGGImages(int GateID, PictureBox pbox) { try { WebRequest request = WebRequest.Create("http://" + server + ".darkorbit.bigpoint.com/jumpgate.php?userID=" + uid + "&gateID=" + GateID + "&type=full"); WebResponse webresponse = request.GetResponse(); Stream responseStream = webresponse.GetResponseStream(); UpdatePictureBox(responseStream, pbox); } catch (Exception) { } }
Thats the main code. It is then called later like this:
CSharp Code:
.... case "4": { if (root.Element("item").Attribute("duplicate") != null) { output = output + Convert.ToChar(948).ToString() + " gate (Multiplier Received)"; } else { output = output + Convert.ToChar(948).ToString() + " gate"; ggcomplete[3][0] = Convert.ToInt32(root.Element("item").Attribute("current").Value); UpdateGGImagesManager(4, pictureBox4); } break; } ....
When the thread runs, even though it is running on another thread, the GUI locks up for about a second. This means I can narrow it down to the Invoke on the main thread, meaning that the PictureBox.FromStream method generates a bit of lag??
Is this right or what the heck is goin on?
Thanks,
Josh


Reply With Quote
