Keep form updated after switching windows?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Al  G

    #1

    Keep form updated after switching windows?

    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


  • Robin Tucker

    #2
    Re: Keep form updated after switching windows?

    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


    Comment

    • Al  G

      #3
      Re: Keep form updated after switching windows?

      Thanks Robin, I'll try it.

      Al G


      "Robin Tucker" <rtgroups@hotma il.co.ukwrote in message
      news:f1pqno$h7q $1$8300dec7@new s.demon.co.uk.. .
      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
      >
      >

      Comment

      Working...