Why the peekMessage statement is required before Getmessage() for creating message queue?
Why the peekMessage statement is required before Getmessage() for creating message queue?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
It’s not required.
What you’ll sometimes see, though, is a thread that isn’t ready to process messages yet, but it wants to be able to receive them in its message queue. New threads do not have message queues right away, but calling
PeekMessageis sufficient to create the message queue. It returns immediately since there is no message, and that allows the thread to continue getting itself ready. In the meantime, other threads can start queuing messages for the new thread. Once the new thread is ready, it callsGetMessageto either retrieve the first message off the queue, or to wait for a message to be put onto the queue.