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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:25:40+00:00 2026-05-10T16:25:40+00:00

What is the proper technique to have ThreadA signal ThreadB of some event, without

  • 0

What is the proper technique to have ThreadA signal ThreadB of some event, without having ThreadB sit blocked waiting for an event to happen?

i have a background thread that will be filling a shared List<T>. i’m trying to find a way to asynchronously signal the ‘main’ thread that there is data available to be picked up.


i considered setting an event with an EventWaitHandle object, but i can’t have my main thread sitting at an Event.WaitOne().


i considered having a delegate callback, but a) i don’t want the main thread doing work in the delegate: the thread needs to get back to work adding more stuff – i don’t want it waiting while the delegate executes, and b) the delegate needs to be marshalled onto the main thread, but i’m not running a UI, i have no Control to .Invoke the delegate against.


i considered have a delegate callback that simply starts a zero interval System.Windows.Forms.Timer (with thread access to the timer synchronized). This way the thread only needs to be stuck as it calls

Timer.Enabled = true;

but that seems like a hack.

In the olden days my object would have created a hidden window and had the thread post messages to that hidden windows’ HWND. i considered creating a hidden control, but i gather that you cannot .Invoke on a control with no handle created. Plus, i have no UI: my object could have been created on a web-server, service, or console, i don’t want there to be a graphical control appearing – nor do i want to compile a dependency on System.Windows.Forms.


i considered having my object expose an ISynchronizeInvoke interface, but then i would need to implement .Invoke(), and that’s my problem.


What is the proper technique to have thread A signal thread B of some event, without having thread B sit blocked waiting for an event to happen?

  • 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. 2026-05-10T16:25:40+00:00Added an answer on May 10, 2026 at 4:25 pm

    Here’s a code sample for the System.ComponentModel.BackgroundWorker class.

        private static BackgroundWorker worker = new BackgroundWorker();     static void Main(string[] args)     {         worker.DoWork += worker_DoWork;         worker.RunWorkerCompleted += worker_RunWorkerCompleted;         worker.ProgressChanged += worker_ProgressChanged;         worker.WorkerReportsProgress = true;          Console.WriteLine('Starting application.');         worker.RunWorkerAsync();          Console.ReadKey();     }      static void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)     {         Console.WriteLine('Progress.');     }      static void worker_DoWork(object sender, DoWorkEventArgs e)     {         Console.WriteLine('Starting doing some work now.');          for (int i = 0; i < 5; i++)         {             Thread.Sleep(1000);             worker.ReportProgress(i);         }     }      static void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)     {         Console.WriteLine('Done now.');     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best/proper technique to share login between two sites. I have website
Is there a proper way, equation or technique in general to say, My web
This yields proper results, but I would like to have the resulting row in
So, I have some function returning a pointer, or NULL on error. Now I'd
I'm trying to figure out the proper technique for performing skipping ahead or seeking
Background: I recently completed a tic-tac-toe game in AS3, using some simple function-based code
I have some code that assigns an object to a generic id variable and
I found the technique below in another StackOverflow issue. It gets the proper Program
I have several applications that I wish to deploy using rpm. Some of the
Im building an app that uses long polling technique and im running into some

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.