Often when doing a given task in a loop c# program did not bother updating the content of controls until the loop ends. So for example when the program has to update the text of a button at the end of each iteration to give the user a feedback about the advance in the process, it will not be done. This of course has been done for good reason, namely forcing the control the refresh will degrades the performance of the process but in certain case the display of the updated text could anyway be desirable. So to force the refresh write the following line in your code:
label1.Text = "Processing 1 of 10 ...";
Application.DoEvents();
The DoEvent() function allow the form to execute all task in the task list, without wait for the last task to finish.
No comments:
Post a Comment