Click here to Skip to main content
15,940,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends....

I am stuck with BackGroundWorker. I learn Three basic steps to do work with Background worker.

Step 1 :- DoWork Event -- In this we do our work. i.e. Call Methods, Function, execute Querys' etc. and also enables background Properties like WorkerReportsProgress
, WorkerSupportsCancellation etc.

Step 2: ProgressChanged event : This is used to increment Progressbar value,and enable's access forms controls.

Step 3 : RunWorkerCompleted Event : It tells Work is completed or not .


But my problem is how to calculate max value for Progress Bar, how to increment Progress bar , because i have to call different methods some will retrieve values from Database, some will do work within the application. I changed style to Marque and set MarqueeAnimationSpeed but due to lot of Processing it hides the Progressbar.

If i put all methods in one Method then call that method in DoWork Event then it hides Progressbar. and shows it after doing all work.

If I call the part which take lot of time in DoWork event. by Calling method BackgrounfWorker.RunWorkerAsync() on btn_Click event then before going to DoWork Event it is executting lines bellow this method after executting all these then it is executting RunWorkAsync() method.

Please help me how to solve this Problem.
Posted
Updated 5-May-12 0:59am
v2

1 solution

 
Share this answer
 
Comments
Varinder Raii 5-May-12 7:14am    
From such example i have gone so many times.

Let me ask my question to you.

I have to Retrieve some values from table then on the basis of this i have to insert some values in some table and then i have to retrieve value from this table. Now after retrieving i have to bind it with datagridview, then i have to set appearance of columns like, some values bold,some right side etc. tell me how should i do it. how should i can increment progrsssbar.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900