Click here to Skip to main content
13,044,705 members (44,180 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a Process running in background worker .
i need to implement another DownloadProgressChangedEventHandler for Downloading Process of the file and need to show Progress in percentage on UI.Complete Code is in Class file

Code sample

public void _backgroundWorkerDoWork(object sender, DoWorkEventArgs e)

Some Code ......

Some Code ......

_wbClient = new WebClient();
             _wbClient.DownloadFile(SeverPath +FileName, DownLoadedFilePath +FileName);


Need to show download Progreess of Webclient using
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
              webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);

on GUI

Please help..
Posted 15-Jan-13 0:10am
Updated 15-Jan-13 0:27am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The BackgroundWorker class[^] offers a method ReportProgress[^] that causes the ProgressChanged[^] event to be risen not in the working thread but in the thread that created the BackgroundWorker. Usually that is the GUI thread. You can therefore call the method in the worker thread and handle the event in the GUI thread, which can change a label without hassle.

Now you have to rename
new DownloadProgressChangedEventHandler(ProgressChanged)
new DownlaodProgressChangedEventHandler(DownloadProgressChanged)

so the method name doesn't interfere with the "other" ProgressChanged method.

Then implement
public void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    DownloadProgressBar.Value = e.ProgressPercentage;


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100