Ben wrote:
Is there any way to stop the above from happening?
The "best" route is almost certainly to run the time-consuming routine in
another thread, as has already been suggested.
However an easier solution that may well still accomplish your goal is to
get the window to repaint itself from time to time.
At regular intervals within your code you can either force the form to
refresh itself:
\\\
Me.Refresh()
///
(assuming the code is running within a procedure within the form itself) or
alternatively allow the application to process all queued events:
\\\
Application.DoEvents()
///
The Refresh method will cause all visual elements of the form to be updated.
This will get your label text update fixed and will get the window to
repaint if other windows have obscured it. You won't be able to interact
with the window however until the routine has finished, as the events will
be queued but temporarily ignored. Once the procedure is finished, all the
queued events will be processed together.
The DoEvents method will allow the screen to repaint and the label to be
updated, and will also process any events that have been queued. This will
allow the user to, for example, move or close the window, click buttons and
interact with other UI elements.
Have a go with these and see if they do what you want.
--
(O)enone