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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:27:13+00:00 2026-05-26T10:27:13+00:00

I have a C++ application which has the following structure: Class AAA: has some

  • 0

I have a C++ application which has the following structure:

Class AAA: has some functions and one of them function that opens a thread.
Class BBB: has some functions and one of them function that opens a thread.
Class CCC: call AAA and BBB that both internaly in their functions open the treads.

In AAA thread in some case I know something that I want to exit the tread and notify both BBB and CCC.
because I am in a thread (Win32Thread) it is a void function I am running in the thread, so I can’t return a value to CCC.

I’m new to C++ (coming from c# area) and don’t know what is the way to do it. (the notification)
note: I can’t change this structure. I can only add or do minor changes in the function of the classes. it is a big process that running in the treads and large code.

Any idea? not a dirty one please, if it possible 🙂

adding a sample will help me very much.

  • 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-26T10:27:14+00:00Added an answer on May 26, 2026 at 10:27 am

    I don’t understand too much your problem, is a bit too generic.
    And you didn’t specify what kind of multithreading libraries are you using.

    To send messages between threads usually Message Queues are used, with wait handles, lock and semaphores to synchornize them.

    Of course you need a safe multithreading queue to send your messages between threads.

    One possible solution:

    If thread A need to send a message to thread B by enqueueing it into thread B queue, waking it up if it is in idle state through a wait event for example.
    Thread B receives the message and respond posting another message in A queue.

    Another possible solution:

    Thread A need to send a message to thread B and need a reply, blocking thread A until the reply is not received.
    Thread A enqueue a message in thread B queue, the message object can be in the function stack. Then he wakes up thread B if it is in idle state and then enters in a wait state through a wait handle or a semaphore for example.
    Thread B, when dequeues the message, write the answer in the object sent by thread A and wakes up thread A from its awaiting state.
    The object field should be marked as volatile because is accessed for read\write by two threads.
    Then thread A uses the value stored in message object and delete the object from the stack.

    Sounds complicated written in words but the implementation is quite straightforward.

    If you are in Windows OS you can just use windows message queue creating invisible message windows, one for each thread. Use PostMessage for the first case, SendMessage for the second case.

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

Sidebar

Related Questions

We have an application which has a heirarchical group structure. Some of the groups
I have a view based application which has some textboxes that I'm trying to
I have an application which has a similar interface to Visual Studio, in that
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have following structure of web application, for which I'm automating testing: <em unselectable=on
I have a Unicode Win32 application that uses 3rd party libraries, some of which
I have an application which has the following characteristics There are Clubs Each Club
I have an application which has to live as a service, I create an
I have an application which has a Projects table and a Users table. In
I have an AJAX application which has used CSS divs to create panels on

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.