Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello and good morning all! I've been working on an application and it loads data from a SQL database. All is finished but my user has requested that I add a progress bar so she knows if it hangs and if it is still processing/downloading).

I have completed a very useful tutorial from CodeProject that helped out a lot. But my question is How do I initiate the progressbar/worker when I click my btnReloadTableData (reload data button)?

Here is the tutorial I found and it is extremely helpful explaining the different pieces of the background worker and progress bar.

Link DaveyM69 posted

I have tried placing the code from below InitializeComponent(); but with no progress to the project. Can someone please help me? Basically I might not fully understand which method to call and where to place it on my btn_click method.
Posted
Updated 10-Mar-14 3:32am
v2

1 solution

As long as you have executed the code in the Shown method:
C#
void Form1_Shown(object sender, EventArgs e)
{
    // Start the background worker
    backgroundWorker1.RunWorkerAsync();
}

The worker should run, and issue progress markers at 1/10th second intervals -- so it will take 10 seconds to finish the background task.

So: use the debugger, and put breakpoints in to check what is going on:
Is the RunWorkerAsync being called?
Is the worker running?
Is the progress event executing?

If the answer is yes to all these, then we would need more details on exactly what is happening.
 
Share this answer
 
Comments
Branden Coker 10-Mar-14 9:53am    
Thank you for your help! It appears it is working correctly. Have a great day.
OriginalGriff 10-Mar-14 9:58am    
And yourself - you're welcome!

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