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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:34:46+00:00 2026-05-31T08:34:46+00:00

I have a WPF application with two background worker threads that operate while loading.

  • 0

I have a WPF application with two background worker threads that operate while loading.

The first one (bw1) is spawned at application start, and the second one (bw2) is spawned after some time has elapsed.

I am in a situation that I CAN’T spawn the second background worker (bw2) from the first one’s (bw1) “worker_completed”.

Currently, I have a class-level bool variable (default false), and set it true in bw1‘s worker_completed.

And at the starting of bw2, I have a check to see if the above bool is false, and if so, bw2 will sleep for 100 milliseconds.

This works, for the most part. I’d like to improve it.

  • Can I use thread priority in bw1 (set it as highest, say) to ensure that bw1 is executed while bw2 sleeps?

  • Is there an event-driven way I can accomplish this goal?

  • 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-31T08:34:47+00:00Added an answer on May 31, 2026 at 8:34 am

    Busy spinning (even with sleep) is a bad idea when you don’t actually know when the event will occur, since you are checking blindly and using system resources unnecessarily.

    Use an AutoResetEvent instead. At the beginning of bw2’s code call ev.WaitOne() and in bw1’s work_completed call ev.Set() to release bw2:

    AutoResetEvent ev = new AutoResetEvent();
    
    // bw1's work completed     
    private void bw1_workCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        ev.Set(); // release bw2 from waiting
    }
    
    // bw2's do work
    private void bw2_DoWork(object sender, DoWorkEventArgs e)
    {
        ev.WaitOne(); // wait for the signal from bw1
        // code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a WPF Application that has a two flavors with a consistent UI
I have two different ways of displaying items in a WPF application. The first
I have a WPF application with two DataGrids that share the same ItemsSource. When
I have a WPF application with two PasswordBoxes, one for the password and another
I have two projects in my solution. The first project is a WPF application,
I have WPF Application where I have One main form and other user controls
I have a WPF application that runs fine under XP as an administrator. When
I have a WPF application (.NET 3.0, VS2008) that displays data in a tab
I have a wpf application (C#) that needs to copy a file to a
Basically I have a WPF application that will display announcements to the user within

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.