How to maintain windows native event loop and windows creation in different thread

Harshithraj1871 1,496 Reputation points
2022-06-13T06:26:50.187+00:00

hi,

I’m building a multithreaded Windows native application. I want all the native interactive operations to be handled by the main thread and the operations like window creation to happen in a different thread by API calls. So, I have my event loop in the main thread, and window creation is done in a different thread. While I follow this kind of structure, the event loop in the main thread is stuck, as the GetMessage() in the event loop is reading from the main thread's message queue while the window and the respective message are in another thread.

Is there any way to post the message from the window thread to the main thread without using the main thread’s threadid? It would be very helpful if you could give any kind of solution for this

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,525 questions
{count} votes

Accepted answer
  1. RLWA32 40,276 Reputation points
    2022-06-13T08:24:16.237+00:00

    Windows have thread affinity. If you want to create windows on multiple threads then each creating thread should have its own message pump (loop).

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful