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 8444737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:28:22+00:00 2026-06-10T09:28:22+00:00

I have a BackgroundWorker that calls a method in a class. The method is

  • 0

I have a BackgroundWorker that calls a method in a class. The method is given a reference to the BackgroundWorker so that it can report back its progress. This pseudocode shows the outline:

void BackgroundWorker_DoWork( object sender )
{
    BackgroundWorker w = sender as BackgroundWorker;
    var c = new ProcessingClass()
    c.someMethod( w )
}

class ProcessingClass()
{
    someMethod( BackgroundWorker w )
    {
        w.ReportProgress(50)
        //calculations...
    }
}

The problem is that when doing the “calculations” after reporting the progress, the program will crash. the debugger jumps to Application.Run( new frmMain() ); in the startup “Program” class, reason given “Exception has been thrown by the target of an invocation.”

If I don’t report the progress, everything works fine. Does anyone know why? My guess is that this has something to do with threads, but I don’t see how.

  • 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-10T09:28:24+00:00Added an answer on June 10, 2026 at 9:28 am

    Just some suggestions:

    1.) Inspect the InnerException property of the TargetInvocationException exception.

    2.) Configure Visual Studio to stop as soon as the exception is thrown:

    enter image description here

    This should help getting closer to the error.

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

Sidebar

Related Questions

I have a backgroundworker which calls a method in the DoWork event. this method
I have a background worker that stops after 100 iterations. Like this: BackgroundWorker bgWorker
I am using a backgroundworker that can have n instances. Problem is the DoWork
I have a System.Threading.Timer that calls its appropriate event handler (callback) every 10 ms
In my windows forms applications I have a class that extends a backgroundworker, let's
I have a small WinForms app that utilizes a BackgroundWorker object to perform a
I have a WPF ListView that I am trying to filter within a BackgroundWorker.
I have a timer tick that I would like to kick off my backgroundworker
lets say i have a background worker in a class that perform db query
I have a multi-step BackgroundWorker process. I use a marquee progress bar because several

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.