Refresh label on front end

  • Thread starter Thread starter Austin Rathe
  • Start date Start date
A

Austin Rathe

Hi,

Is there a command I can use in VB.NET to force my program to update a
label in the UI? I basically have a label that, in theory, should
display what the app is currently doing. However, the systems seems to
get so "busy" that the label is never updated, until the process is
finished (the system is essentially a batch process, triggered by a
button click).

All tips appreciated.

Thanks,

Austin Rathe
 
Hi,

Is there a command I can use in VB.NET to force my program to update a
label in the UI? I basically have a label that, in theory, should
display what the app is currently doing. However, the systems seems to
get so "busy" that the label is never updated, until the process is
finished (the system is essentially a batch process, triggered by a
button click).

You can call the Application.DoEvents() method to force the application to
process any pending Windows message and hence refresh the Label. However,
it would be much better to do your long running task in a worker thread so
that the UI thread is not frozen. This can be more complicated than doing
everything in the UI thread but the user experience will be greatly
improved as the application will not look frozen. Plus this will make your
code more readable and easier to maintain since you won't have to remember
to call Application.DoEvents() everywhere in order to keep the UI
responsive.
 
Mehdi,

Thanks for the tip. The app is only for my own use so the user effects
aren't a problem!

Thanks for your help, I'll try it.

Cheers

Austin
 
Back
Top