Link to home
Start Free TrialLog in
Avatar of jtran007
jtran007

asked on

Create dialog box with progress bar and button

Hi Expert,
I have a lenghtly process ( retrieve data from MySql and do some calculations) I'd like
while I am processing data, I can use a pop up dialog box where there is progress bar
to monitor the ongoing proces, and a CAncel button that uer can abort the process if it
takes too long.
Could you how to implement this task?
Thanks,
JT
Avatar of CuteBug
CuteBug
Flag of India image

First of all you need to perform your lengthy task using BackgroundWorker

http://dotnetperls.com/backgroundworker
http://msdn.microsoft.com/en-us/library/cc221403%28VS.95%29.aspx

Based on the progress reported by the background worker you can update the progress bar of your dialog box.

Background worker also supports cancellation.
Avatar of jtran007
jtran007

ASKER

Hi Expert,

Thanks How do I use progessba to report the status of background task, and use cancel button to
cancel background task
Since I am new to c#, please help

JT
Hi Expert,

I use ThreadPool to create a number of threads on the fly. I don't know how to link
progress bar with threadpool ; with separate thread I know how to do.

Thanks,
JT
ASKER CERTIFIED SOLUTION
Avatar of CuteBug
CuteBug
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Expert,

Thanks for sample code. It's working perfectly.
If I put a Cancel button to allow user to cancel the thred pool if it takes too
long (some problem with dtabase). How can it send envent to trhread pool.
Could you give me a sample example  too?

Thanks for your help.
JT
Hi Expert,

I have two questions:
1- Can I use both Background Worker and ThreadPool at the same time?
2- While usign ThreadPool, I create thousands small threads taks that queries
some data from Mysql, the problem is that I have maximum 25 ManualEvents allowed
to use. Is there other ways  rather than use ManualEvent? Since each my small thread
queries data and do some calculation, and save it to its state. When all threads finish
calculations, I display their results in datagridview.

I am looking forward to your help.
Thanks,
JT
Avatar of Alan Hardisty
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.