views:

46

answers:

2

I have a Windows form that I'd like to be able to refresh with a status of the work that's going on in the background in different threads.

Problem is, even if I change the label on the form, it doesn't immediately refresh; it seems that the work happening on the other worker threads is preventing the screen from updating.

How do I force the form to refresh the new value of the status label immediately?

+2  A: 

I asked a similar question a few days ago.

The best option, that I'm using now, is a separate thread running a status form.

This is the suggested solution, that I received, which works by displaying a form, which then updates on a 'tick', and ensures that regardless of whether the UI on your app is updated or not, the status form is updated.

Cheers

Nick Haslam
+2  A: 

Shortest path:

label1.Text = "....";
label1.Update();
Henk Holterman
I just slapped my forehead and shouted "DOH!"Answer credit for the shortest path... :)
Shaul
If the screen isn't updating because of work on the worker threads, then updating the Label won't do anything, because the screen isn't updating.... Will it ?
Nick Haslam
Nick, just try it. See http://stackoverflow.com/questions/952906/how-do-i-call-paint-event/952964#952964
Henk Holterman
@Old Nick: IIRC Control.Update refreshes the Control immediately, bypassing the message queue. So yes, it should work in a busy thread, too.
nikie