Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
martin - 29 Jul 2004 06:10 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.