Form Refreshes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a WinForms application that displays a dialog. A button on this
dialog causes a routine to execute that can take upto 10 minutes to run.
This routine raises events to inform the dialog of it's progress. The Dialog
updates the statusbar and a progress bar with the status it receives.

My problem is if the dialog is covered in any way by another window it
doesn't redraw itself. Is there a way to fix this problem? Is there an
event I can catch that will let me know that the Dialog needs to be refreshed?
 
The paint event should indicate this. You should be able to redraw using the
..Refresh() method of the form.
Can't test this at the moment but should do the trick.

br,

Mark.
 
Hi Steven,

Thanks for your post.

First, in your Button.Click event handler, for your 10 min routine, does it
wait in some OS function(like synchronize Device I/O function) or just stay
in a long processing loop? If your Button.Click event handler just fall in
a user mode long processing loop, I suggest you call Application.DoEvents()
method in each loop, this method will peek all the messages(including
WM_PAINT message) from current thread message queue, then process it. It
will give your application a responsive UI.

If your Button.Click event handler is waiting in OS function synchronize
operation such as Device I/O, I think we should use multithreading, just
place the long processing device I/O code in another worker thread. Then
our UI main thread will not be blocked, and we will have responsive UI. In
..Net, we can achieve this with asynchronize delegate, for more information,
please refer to Chris Sells' great article:
"Safe, Simple Multithreading in Windows Forms, Part 1"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/htm
l/winforms06112002.asp
=================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Yes Jeffreys post is the way to go. This (having tested it now) does not
work as you wish.

br,
Mark.


Mark Broadbent said:
The paint event should indicate this. You should be able to redraw using
the .Refresh() method of the form.
Can't test this at the moment but should do the trick.

br,

Mark.
 
Thanks Jeffrey, this really helped. My app is now responsive during the long
running process, including progress updates.

-
Thanks,

Steven Perry
 
Cool. If you need further help, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top