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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:04:16+00:00 2026-06-07T02:04:16+00:00

In one of my class i’m launching a thread using the following method: HANDLE

  • 0

In one of my class i’m launching a thread using the following method:

HANDLE hThread;
unsigned threadID;
hThread = (HANDLE)_beginthreadex( NULL, 0, &myThread, NULL, 0, &threadID );

And from this thread I would like to call a method that has to be called from the main thread (the method is interacting with the UI) but I really don’t know how to do it since the main thread can’t wait until “myThread” notifies it.

I have seen a lot of

while(true){
  //wait something from myThread
}

But I can’t wait this way!

Any ideas?

  • 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-07T02:04:18+00:00Added an answer on June 7, 2026 at 2:04 am

    Since your main thread is UI, you can send a message to it.

    #define WM_USER_EXECUTE_MY_CODE (WM_USER + 1000)
    

    Your UI message loop should process the message:

    // API code
    // LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    // create message map yourself if you're using MFC
    
    if (iMsg == WM_USER_EXECUTE_MY_CODE)
    {
        // execute your code must run in main thread
    }
    

    And in your worker thread, send UI a message

    // HWND hwnd = handle to main UI window
    // if you need some parameters, send them through WPARAM or LPARAM
    SendMessage(hwnd, WM_USER_EXECUTE_MY_CODE, 0, 0);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one class DataThread inherited from Thread. I am using two DataThread objects
I have one Class with 2 methods. The first method is called by the
I am trying to use one class to handle all of my CRUD on
// Method One class ClassName { public: ClassName() : m_vecInts() {} private: std::vector<int> m_vecInts;
I have one class called MainMenu, which has a method called switchViews, with 2
In one class I have a library project with a file class1 with namespace
In one class there is a list with all friends and their IDs. Now
In one class, I define an NSMutableArray with getters and setters: @interface ArrayClass :
i make one class file for jar. and this class have use wurfl. and
I have this one class: say InterClass . This class is declared in say,

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.