Keep form updated after switching windows?

  • Thread starter Thread starter Al G
  • Start date Start date
A

Al G

Hi,

(VS2005, SP1, VB windows form)

I have a VB application that reads large files. While it is running, a
record counter is being updated and shown in a text box. If I switch to
another window, when I come back to the form, the text box is no longer
being updated. In fact the form seems frozen until the app ends. What am I
missing?

Al G
 
Hi Al,

You need to be reading your file on a separate thread. If you aren't, then
Windows Forms never gets a chance to handle events in it's message queue,
including the form or control "OnPaint" messages; at least for the duration
of the file operation. One possible solution is to use "DoEvents ()" inside
your file reading loop if you don't want to use threads but I would strongly
recommend against that as this is not a natural pattern for this kind of
task.


Robin
 
Back
Top