I have a thread like this:
DWORD WINAPI message_loop_thread(LPVOID dummy) {
MSG message;
while (GetMessage(&message, NULL, 0, 0)) {
TranslateMessage(&message);
DispatchMessage(&message);
}
}
And i start it with CreateThread
:
DWORD thread_id;
CreateThread(0, 0, message_loop_thread, 0, 0, &thread_id);
This seems to work, but how can i correctly close this thread? Normally the thread is waiting for GetMessage
so the thread is blocked i think.
Is there a good way to do this? I tried TerminateThread
, but this hangs, and i think it's not a good solution to stop the thread.
Has someone an idea?
best regards Benj Meier