Reputation: 660
I am currently writing an application in C# that processes some XML among other things. Some of the XML docs can be quite big so I added in a label to show the user that characters are still being processed and that the application is still running.
The actual XML building is being run in a different thread but the XMLInProg and charsProcessed are class variables which the main thread can see and use them to update the GUI.
For some strange reason, I can only get the status label to update whenever I get a messagebox to popup along with the update. Can anyone explain why?
Thanks.
This does not work...
while (XMLInProg)
{
status.Text = "Building XML... " + charsProcessed + " characters processed";
}
But this will work
while (XMLInProg)
{
MessageBox.Show("Works now");
status.Text = "Building XML... " + charsProcessed + " characters processed";
}
Upvotes: 0
Views: 1115
Reputation: 3311
Call the refresh method on the label (within the loop):
status.Refresh()
Upvotes: 2