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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:08:41+00:00 2026-05-29T04:08:41+00:00

I would know if it’s dangerous Run A Backgrounworker2 in a RunWorkerComplete1 like this

  • 0

I would know if it’s “dangerous” Run A Backgrounworker2 in a RunWorkerComplete1 like this :

public void backgroundworker1RunComplete (Object sender , RunworkerCompleteEvent e)
{
    Backgroundworker2.runAsync();
}

Could be any deadlocks , various problems , etc?
Becouse maybe i have only 2 alternatives :

Run Backgrounworker2 async in RunComplete1 or Use a ManualReset Event where i reset when i enter in BackGroundWorker DoWork1 and i Set() in WorkerComplete1

Number 1)

  private void BackgroundWorker1RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  {
       backgroundWorker2.RunAsync();
  }

Number 2)

 private void BackgroundWorker1RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  {
       manualReset.Set();  
  }

 private void BackGrounWorker2DoWork(Object sender , DoWorkEventArgs e)
 {
   manualReset.WaitOne();
  //Do Stuff
 }
  • 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-29T04:08:42+00:00Added an answer on May 29, 2026 at 4:08 am

    background threads starting background threads (which is basically what you’re doing here) is perfectly valid. I’ve seen and built algorithms that depend on just that, and there was even one where the same BGW restarted itself with a different command which triggered different logic (not my design, and I had my issues with it, but it got the job done).

    You just have to make sure you know what you (and your background threads) are doing, and what they shouldn’t be doing:

    • Make sure there are no possible deadlocks, where both BGWs are waiting for the other to complete. In this case BGW1 launches BGW2 (which hasn’t been running) and seems to be done after that, so this is unlikely. However, if both run at the same time and wait for the other to complete at any given point, or acquire locks on different objects, both of which are needed by both BGWs, there can be issues.

    • Don’t ever try to directly get or set property/field values, or call methods, on a form from its BGW. If you must do this, use Control.Invoke or Control.BeginInvoke. You can avoid having to know the difference with a simple extension method or two.

    Here’s that extension method (seems to be a bug in the formatter; can’t put a code block in the middle of a list):

    public static void InvokeIfNecessary(this Control ctrl, Action action)
    {
        if(ctrl.InvokeRequired)
        {
           ctrl.Invoke((MethodInvoker)action);
           return;
        }
    
        action();
    }
    

    You can create other variations on this to take or return values, but with judicious use of external closures you can use this for almost anything.

    • Don’t forget to wait for, or cancel, BGWs when closing their containing Form. This may require you to structure the doWork method (and long-running methods it calls directly) to know if and when to quit when signalled from outside.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like know some reference. I know i can googling it. but prefer
I really hope would know how to do this cause I'm a total newbie
Apologies is this is something a more seasoned R user would know, but I
If you ever tried to use MFC and OpenCV together, you would know this
I would like to run a WebSocket server off a worker role in Azure.
I would know how can I solve this issue when I try to commit
i would like to know if a point in a plane segment, and its
Most Photoshop people would know what this does, basically it re-sizes the image removing
I would know what this symbol should mean ?
Was wondering whether anyone would know why do we use the parentheses in this

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.