show modal dialog / progess and move on ..advice please..

  • Thread starter Thread starter martin
  • Start date Start date
M

martin

Hi

I have a long running task and while it is being performed I wish to show a
modal dialog that displays the progress of my task..


what I am doing is this


'start task

frmWait.ShowDialog(Me)


'perform task and update the dialog "frmWait"

take frmwait down.



however execution of the program always stops when I show the dialog and
waits for the dialog to be dismissed.
what I would like to do is show the modal dialog while my long running task
is being preformed.

should I be doing this another way, can anybody please advise.

cheers

martin.
 
Hi Martin,

When yo use the ShowDialog( ) method of the Form class, you are showing a
MODAL dialog box. This means that, by definition, the invoking process will
wait for the dialog to be visually removed (either closed or hidden) before
continuing its processing. Consider the following code (line numbers are
for reference only):

1 Dim myConfirmationForm as New ConfirmationForm
2 Dim userResponse as System.Windows.Forms.DialogResult

3 userResponse = myConfirmationForm.ShowDialog( )
4 If userResponse = System.Windows.Forms.DialogResult.OK Then
...
5 End If

In the above example, the code execution would stop at line 3 until
myConfirmationForm was closed or hidden (it needs the results of the form in
order to decide what to do next).

Instead, use the Show( ) method of the form. This is a MODELESS invocation
of the form, and allows the processing to continue. As a side note, if the
processing that occurs is really long, you may want to use a separate thread
(as suggested by Claes earlier).

HTH,
Derrick
 
Hi martin,

Progress bar or progress form either ways you need to use worker thread to
perform the operation.
Anyways, if the processing is simple and you have control over it you can
show the form modaless (Show rather than ShowDialog) and call periodically
Application.DoEvents() in order to keep the application responsive. However
my suggestion is to use a worker thread.
 
Back
Top