Click to See Complete Forum and Search --> : Thread peekmessage problem


vc185002
March 27th, 2006, 12:50 AM
Hi all

if(MyThread_Handle_Exist())
{
postmessage();
}
else
{
_beginthread(MyThread);
}
MyThread()
{
//processing;

if(peekmessage())
// repeat the thread;
}


the problem is how can i get the message in the thread, i use to chk with the Peekmessage at the end of the thread but it is not working properly
The thread has to die if there is no other message for the thead. Kindly suggect any solution

woking on VC++ 6.0 without MFC

kuphryn
March 27th, 2006, 02:29 PM
Is PeekMessage() called from inside a loop?

Kuphryn

vc185002
March 27th, 2006, 11:46 PM
PeekMessage () is called before existing form the thread : not in loop

Bornish
March 28th, 2006, 12:46 AM
Have you tried using PM_NOYIELD flag (combined with PM_REMOVE) as wRemoveMsg?
I think your thread peeks for message before the message comes in the queue, and the parent thread sees it valid because it wasn't released yet (parent thread checks exactly between PeekMessage and return).
Regards,