The standard non-busy message loop is:
Code:
BOOL bRet;
MSG msg;
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
If you want a delay in a PeekMessage() loop, yes you can use Sleep(1)(not Sleep(0)*) to give up the rest of the thread time slice when you have done whatever you need to do.
*Apparently, Sleep(0) will only yield to threads with the same or higher priorites, while Sleep(1) or above will yield to any thread.