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

  • Home
  • SEARCH
  • 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 6021069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:39:32+00:00 2026-05-23T03:39:32+00:00

Using C# .NET 3.5. It seems I’m not the only one, since a search

  • 0

Using C# .NET 3.5.

It seems I’m not the only one, since a search seems to bring up a lot of similar questions, however reading through them I seem still to be missing the solution.

I’m raising an event with a button click on my UI, which is then supposed to start a backgroundWorker to get some time consuming work done – in this case, I want it to collect information from a form and a) write to an xml file as well as b) insert the information into a remote database.

This is exactly what the backgroundWorker was designed and intended to do I believe.

Here is the event raising code.

private void btnFinish_Click(object sender, EventArgs e)
{
    clkFinish.setInstant();
    curAct.setTimeFinish(DateTime.Now);
    btnStart.Enabled = true;
    bgwDataWorker.RunWorkerAsync();
    for (int i = 0; i < 20; i++)
    {
        Console.WriteLine("Thread a: " + i);
        Thread.Sleep(100);
        if (i == (20 - 1))
        {
            Console.WriteLine("Finished");
        }
    }
    
}

As you can see, I have some code there which I’ve used as a counterbalance to the background worker code, which is here:

private void bgwDataWorker_DoWork(object sender, DoWorkEventArgs e)
{
    Console.WriteLine("Running in a different thread now");
    int count = 0;
    for (int i = 0; i < 21; i++)
    {
        Console.WriteLine("Thread b: " + i);
        Thread.Sleep(100);
        (sender as BackgroundWorker).ReportProgress(5 * i, null);
        if (i == (21 - 1))
        {
            count = i;
        }
    }
    e.Result = count;
}

So far, everything seems to be working up to this point.

My problem is that when the code in the DoWork method is finished, nothing is happening. Here are the ProgressChanged and RunWorkerComplete methods.

private void bgwDataWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    Console.WriteLine(e.ProgressPercentage);
}

private void bgwDataWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    Console.WriteLine("Result is " + e.Result.ToString());
    
}

This has me baffled.

I’ve tried running the examples from MSDN and I’m experiencing the same problems. RunWorkerCompleted and ReportProgress events are simply not being raised for some reason and I don’t understand why.

Thanks for reading.

Alan

  • 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-05-23T03:39:33+00:00Added an answer on May 23, 2026 at 3:39 am

    I had the same problem and I just figured out the answer.

    In the properties of the backgroundworker, make sure that ProgressChanged and RunWorkerCompleted list the name of their functions (mine are called ‘backgroundWorker1_ProgressChanged’ and ‘backgroundWorker1_RunWorkerCompleted’ respectively).

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

Sidebar

Related Questions

I want to test ASP.NET application using NUnit, but it seems WebConfigurationManager.ConnectionStrings collection is
I'm trying to parse some JSON using the JSon.Net library. The documentation seems a
I'm using .NET 3.5. I have two string arrays, which may share one or
Using Quartz.NET it seems like I need to name every job I create. Is
Using .Net (C#), how can you work with USB devices? How can you detect
Using .NET 1.1, I have a DataGrid that contains three columns for each row.
Using .Net 3.0 and VS2005. The objects in question are consumed from a WCF
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
I am using .NET remoting to retrieve periodic status updates from a Windows service
I am using .NET Remoting. My server/hoster is a Windows Service. It will sometimes

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.