Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to handle progress bar using backgroundWorker events while copy data one disk to another??How to handle backgroundWorker process?
Posted
Updated 21-Jul-13 20:58pm
v3
Comments
Thanks7872 22-Jul-13 2:46am    
https://www.google.co.in/search?q=progress+bar+in+c%23&oq=progress+bar+&aqs=chrome.5.69i57j69i65l3j0l2.6880j0&sourceid=chrome&ie=UTF-8
midnight_ 22-Jul-13 2:57am    
Asked a hundred times, and there are just as many examples of this.
MSDN has a code example below:
http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar%28v=vs.100%29.aspx

Hi,
I will just ask you that in this case Google in your friend. Start even by this and you can find many discussion like this: http://stackoverflow.com/questions/6044629/file-copy-with-progress-bar

Best regards.
 
Share this answer
 
v2
Comments
lukeer 22-Jul-13 4:23am    
No need to wrap that in "pre" tags. It's plain text. Therefore I removed the tags for you.
It's all pretty easy:
C#
    BackgroundWorker worker = new BackgroundWorker();
    worker.WorkerReportsProgress = true;
    worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
    worker.DoWork += new DoWorkEventHandler(worker_DoWork);
    worker.RunWorkerAsync();
    ...

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
    myProgressBar.Value = e.ProgressPercentage;
    }

void worker_DoWork(object sender, DoWorkEventArgs e)
    {
    BackgroundWorker work = sender as BackgroundWorker;
    for (int i = 0; i < 100; i++)
        {
        // Do something
        work.ReportProgress(i);
        }
    }
 
Share this answer
 
Comments
Makarand Borawake 22-Jul-13 3:22am    
Thanks....
Whatever file coping operation/backgroud operation done in worker_Dowork()?? Am I right??
OriginalGriff 22-Jul-13 4:47am    
Yes - hence the "Do something" comment! :laugh:
Makarand Borawake 22-Jul-13 5:16am    
Thank You!!
OriginalGriff 22-Jul-13 5:27am    
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