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.
Claes Bergefall - 29 Jul 2004 08:40 GMT
Run your task in a separate thread
/claes
> Hi
>
[quoted text clipped - 21 lines]
>
> martin.
LEBRUN Thomas - 29 Jul 2004 08:43 GMT
Have you try to use a Progress Bar ?

Signature
LEBRUN Thomas
http://morpheus.developpez.com
> Hi
>
[quoted text clipped - 21 lines]
>
> martin.
Derrick [MCSD] - 29 Jul 2004 14:42 GMT
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
>
[quoted text clipped - 21 lines]
>
> martin.
Stoitcho Goutsev \(100\) [C# MVP] - 29 Jul 2004 15:02 GMT
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.

Signature
HTH
Stoitcho Goutsev (100) [C# MVP]
> Hi
>
[quoted text clipped - 21 lines]
>
> martin.