I have a function that checks for messages within the program like so:
Code:
void *MessageCheck(void *ptr);
void *MessageCheck(void *threadID)
{
printf("Begin!\n");
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
{
printf("Exit?\n");
done=TRUE;
}
else
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
}
and when I try to initialize this thread using:
Code:
pthread_create(&threads[0], NULL, MessageCheck, (void *)0);
pthread_join(threads[0], NULL);
the printf("Begin!\n") keeps looping, which it is supposed to, but absolutely no messages are noticed, no matter what i do, keyboard input, mouse nothing and on top of that the program freezes... I am running this in an infinite loop like so:
Code:
while(done==FALSE)
{
pthread_create(&threads[0], NULL, MessageCheck, (void *)0);
pthread_join(threads[0], NULL);
}
and what I think should be happening is that it will keep running until it receives a quit message then exit the while loop, but when I try to quit it wont acknowledge that I even sent a message...
Im really confused right now and would like some help
The reason I am confused is because it seems to be calling the thread fine, and executing things normally, but it just seems to skip everything that deals with the loops, and I am also having problems with another thread writing to the screen with OpenGL, but thats for after this is fixed, hopefully they will fix eachother