Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to report progress of a background worker created and running in another class to UI
    text
    copied!<p>I have a button which calls a class to initiate a background worker. Everything works fine, except I want to report progress to the UI(which has the button) to be updated with background worker progress changed. I Have tried a lot things but could not succeed. The progress changed does not simply fires.</p> <p>Here is the code for initiate background worker:</p> <pre><code>var backgroundWorker = new BackgroundWorker(); ListBackgroundWorkerRunning.Add(path, backgroundWorker); backgroundWorker.WorkerReportsProgress = true; backgroundWorker.DoWork += (sender, e) =&gt; { _fileUploadRepository.UploadFiles(path); var directoryConfiguration = new DirectoryConfiguration(); directoryConfiguration.UpdateProgressBarHandler(10); //BackgroundWorker worker = sender as BackgroundWorker; //directoryConfiguration.ProgressChanged += directoryConfiguration_ProgressChanged; }; //backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; backgroundWorker.RunWorkerCompleted += (sender, e) =&gt; { _crudOperation.UpdateDatabaseWithCrawlFinishedNotification(path); RemoveCrawler(path); InitializeWatcher(path); }; backgroundWorker.RunWorkerAsync(); </code></pre> <p>Here is progress_changed event :</p> <pre><code>//void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) //{ // var directoryConfiguration = new DirectoryConfiguration(); // directoryConfiguration.Invoke(new Action(() =&gt; directoryConfiguration.progressBar1.Value = e.ProgressPercentage)); //} </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload