How to show popup progress window?

G

Guest

I try to save a DB table and it takes few minutes. So I decide to add a popup
progress window. When it’s done the saving work, program code will close the
window.

I created a progress window form with a timer and a ProgressBar control, and
it looks OK. The problem is to open and show the progress window in main UI
thread. I use form’s “ShowDialog†method, but the progress window blocks the
main thread execution until I dismiss the dialog. If I use “Show†to open the
progress window modeless, the progress window is not updated by timer.

The popup progress window is used very popular. Is there an easy way to open
a popup window? Where can I find a sample?
Thanks.

Shaw
 
B

Brandon Potter

Shaw,

You need to process your DB work in a background thread and show the window
in the main thread. The two threads can share a common class (i.e. a class
that has a PercentComplete property that the progress window can go by), but
you are correct that the main thread execution will be held up for as long
as the dialog is open.

Let me know if you need an example (and if so, what language you're working
in).

Brandon
 
G

Guest

Thanks Brandon, I need an example, and currently I work on VB.NET. You can
post the example here or send it to my private email address
(e-mail address removed). It’ll save my time.
Thanks again.

Shaw
 
T

Tom Krueger [MSFT]

Hello,

As Brandon said you will need do the work in a background thread.

Here is some information that should help.

Chris Sells has a 3 part series on Multi-threading. I believe part 3 is the
best one for your situation.
http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp

Also, I find the Asynchronous ProgrammingOverview to be very useful and a
good starting point.
http://msdn.microsoft.com/library/d...html/cpovrasynchronousprogrammingoverview.asp

--
Tom Krueger

Blog - http://weblogs.asp.net/tom_krueger
Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility


This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

I am surprised, the little “progress bar†window causes me big trouble. I am
going to run table access (or saving) at another thread. But I have question
before I spend time to implement.

How to close popup dialog in main thread by another DB operation thread?

Since I open progress popup window by calling “ShowDialog†method, the main
thread just loops to wait user to dismiss the model dialog. It looks main
thread is stuck on “ShowDialog†method and doesn’t want to go anywhere. Can
another thread call progressbar form’s “Close†method to dismiss the dialog?

It’s better if there is an example.
Thanks.

Shaw
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top