How to refresh in a loop?

  • Thread starter Thread starter Axel Dahmen
  • Start date Start date
A

Axel Dahmen

Hi,

I've written a progress window in C#. While looping through a list of files
I want to display the current file and the updated progress bar. However, no
visual update is performed during the loop. Can someone please enlighten me
on how to easily return control to the message pump during the loop?

TIA,
Axel Dahmen
 
Application.DoEvents() pumps the message queue for your
application and will re-draw screens, forms, controls etc
etc
 
That's right, but DoEvents has some nasty side-effects, so I'd suggest if
DoEvents is not really necesssary, that you would use the Refresh method.
 
Out of curiousity, what kinds of "nasty side effects" are you referring to?

Jason Dorie
 
You end up with 2 threads: one handling the UI, and the other one handling
your loop. This is probably not what you want... :-)
 
Back
Top