Form.Update in Windows Xp

  • Thread starter Thread starter Tim Wilson
  • Start date Start date
T

Tim Wilson

By the last few lines in your post it sounds like you're not currently using
a thread but I'd better ask up front... are you calling form.Update() from a
different thread other than the main thread (aka a new thread)? UI updates
should be performed on the UI (main) thread. Something to try is to call
Application.DoEvents() after calling Update() to see if that helps.
 
Hello everyone:

I'm developing an application that executes a long algorithm and I want to
show a progress bar, and every time the progress bar is updated, I also
update the main window, so the window refreshes the invalidated areas.

I was developing in win2k and everything works fine, but now Im using WinXp,
and the form.Update () is ignoring my calls, so the application looks like a
big white box and the user can not know where the progress bar is.

Is that a bug? (Im afraid it is a feature..) Is there any way to do that
without having to create threads or some things like that??
 
Hello Tim:

Im using a single thread, and the reason to not use the Application.DoEvents
method is avoid users for clicking on menus or buttons while the process is
still running.
 
The other option, then, might be to have your algorithm run in another
thread and Invoke() back to the UI thread when you want to update the user
interface (progress, label text, etc.).
 
Of course Tim,

But I consider this should not be necessary.. Why can't I simply revalidate
the invalid areas and repaint my window?
I sould be able to call a method (Update) and get the window repainted, so
it can be guaranteed that the window is painted and all its areas are valid
when the code continues it execution
In Windows 2000 it works ok.

Any idea to perform this in a acceptable manner?
 
I think you've successfully run me out of ideas. Application.DoEvents is
usually ok in simple situations and for complicated scenarios off-loading
the computation to another thread is better. The latter is extreme but
should work.
 
Back
Top