I have a Windows Form with a label and a picture box. To retreive an image from a web service I use a thread.
The user click on a button and first the label must be displayed and then new thread is started to retrieve the image. This is the code:
private void menuItem1_Click(object sender, EventArgs e) { etiquetaCargando.Visible = true; this.Invoke(new System.Threading.ThreadStart(RequestImage)); }
The problem is this: label etiquetaCargando doesn’t appear.
I’m programming on Compact Framework.
What it’s happening?
Thanks!
The question is unclear, but by using Invoke, you are defeating the purpose of having the image request on a separate thread. (You might notice that your interface becomes unresponsive while the request is happening)
Instead, it is better to create a new thread object, start it, and then use the Invoke to set the image (after it has been retrieved), something along the lines of
this assumes that you have a method SetTheImage which will actually do the job of displaying the image on your form.