Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8268961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:04:06+00:00 2026-06-08T06:04:06+00:00

EDIT: Solved by adding missing progress changed event handler. I’m porting a WPF VB.net

  • 0

EDIT: Solved by adding missing progress changed event handler.

I’m porting a WPF VB.net application to C# and am having an issue with a background worker that has a DoWork method in a different class. I have a suspicion that I am not casting the background worker correctly or I may need a handler?

The vb sample code works fine and the progress bar indicates properly, the C# code seems like it fires the bw.RunWorkerAsync(); method as it reports as IsBusy=True but there is no other response, progress or calls to the external class (as far as I can tell).

This is a WPF application and the issue is regarding a Usercontrol trying to report progress from a public class outside of the control.

If someone could point me in the right direction I would really appreciate it.

The C# sample code

 namespace testApp.Usercontrols
    public partial class ucHome : UserControl
    {
        public Sharing.clsDownloadCollection foo = new Sharing.clsDownloadCollection(); 
         BackgroundWorker bw = new BackgroundWorker();



     public ucHome()         
{       InitializeComponent();
 }

private void Button1_Click(object sender, RoutedEventArgs e)
    {


        bw.WorkerReportsProgress = true;
        pBar.Maximum = 50000;   //progress bar on ucHome
        pBar.Value = 0;

        **// Indicates IsBusy=True when debugging but can't see any further activity
         bw.RunWorkerAsync();
        //**

    }

 public void bw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
          var foo=new foo();

         // possible problem?
           foo.DoWork((BackgroundWorker)sender);

        }

        public void bw_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
        {

            this.pBar.Value = e.ProgressPercentage;
        }

The external class different project folder/namespace

 namespace testApp.Sharing
{
//different namespace /folder than ucHome
 public class foo 

{
public void DoWork(BackgroundWorker bw)
{
    for (int i = 0; i <= 50000; i++) {
        i += 1;

        bw.ReportProgress(i - 1);
}
}

}

The sample VB code that works as expected.

    Public Class ucHome 'user control
Public foo As New foo
Friend WithEvents bw As New BackgroundWorker
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        bw.WorkerReportsProgress = True  
        pBar.Maximum = 50000
        pBar.Value = 0
        bw.RunWorkerAsync() 

    End Sub
    Private Sub bw_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bw.DoWork
          'possible my C# is not casting correctly?
        foo.DoWork(DirectCast(sender, BackgroundWorker)) 

    End Sub

    Private Sub bw_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bw.ProgressChanged
       Me.pBar.Value = e.ProgressPercentage
    End Sub

End Class

the class foo that user control calls

Public Class foo

  Public Sub DoWork(ByVal bw As BackgroundWorker)
        For i As Integer = 0 To 50000
            i += 1
         bw.ReportProgress(i - 1)
        Next
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:04:07+00:00Added an answer on June 8, 2026 at 6:04 am

    Solved by adding missing backgrounder ProgressChanged event handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

edit This question is solved! Having something weird. I'm using html { font-size: 100%
Edit: Solved, I wasn't using 'validate()' after adding components. I have a GUI class
EDIT: solved, look below for my solution. first of all, this is my very
Edit: [Solved] : It seems that the getTableCellRendererComponent of the CustomTableCellRenderer is called every
Edit: Solved. Hi, I'm starting with Qt, I try to connect a slot to
edit: Solved - mod_rewrite was the problem I can't get CI to work as
EDIT: SOLVED Thanks Brooks. Your question led me to keep digging into if the
EDIT: solved it, turns out I should use %c not %s because foodSelect and
[EDIT: Problem solved. Please see my answer below.] In my app I call the
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.