Waiting...
-
Hi, Sleep() function makes application sleep for specified time, but it blocks the thread from processing anything. How can i make application sleep for some time but still process the messages? (e.g. equivalent to DoEvents in Visual Basic 6) ----- Don't look back... See your stomach...
-
Hi, Sleep() function makes application sleep for specified time, but it blocks the thread from processing anything. How can i make application sleep for some time but still process the messages? (e.g. equivalent to DoEvents in Visual Basic 6) ----- Don't look back... See your stomach...
The sleep() lets sleep the thread where it's inside. If you let sleep the WinThread, so all the windows will sleep too. You need to use workerthreads, there in you can let sleep the threads as long as you want and the windows will not be affected ... Good luck
-
Hi, Sleep() function makes application sleep for specified time, but it blocks the thread from processing anything. How can i make application sleep for some time but still process the messages? (e.g. equivalent to DoEvents in Visual Basic 6) ----- Don't look back... See your stomach...
This is for UI thread:
void Delay(DWORD dwMsecs, BOOL bBlocking)
{
static BOOL bInDelay = FALSE;if (bInDelay) return; bInDelay = TRUE; DWORD dwStrtmsecs, dwCurmsecs; MSG msg; dwStrtmsecs = dwCurmsecs = ::GetCurrentTime(); do { if (!bBlocking) { if (::PeekMessage(&msg, NULL, 0, 0, PM\_REMOVE)) { if (msg.message == WM\_QUIT) { ::PostMessage(NULL, WM\_QUIT, 0, 0L); break; } else { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } dwCurmsecs = ::GetCurrentTime(); // check for timer overflow condition if (dwCurmsecs < dwStrtmsecs) dwStrtmsecs = dwCurmsecs; } while ((dwCurmsecs < (dwMsecs + dwStrtmsecs))); bInDelay = FALSE;
}
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
-
This is for UI thread:
void Delay(DWORD dwMsecs, BOOL bBlocking)
{
static BOOL bInDelay = FALSE;if (bInDelay) return; bInDelay = TRUE; DWORD dwStrtmsecs, dwCurmsecs; MSG msg; dwStrtmsecs = dwCurmsecs = ::GetCurrentTime(); do { if (!bBlocking) { if (::PeekMessage(&msg, NULL, 0, 0, PM\_REMOVE)) { if (msg.message == WM\_QUIT) { ::PostMessage(NULL, WM\_QUIT, 0, 0L); break; } else { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } dwCurmsecs = ::GetCurrentTime(); // check for timer overflow condition if (dwCurmsecs < dwStrtmsecs) dwStrtmsecs = dwCurmsecs; } while ((dwCurmsecs < (dwMsecs + dwStrtmsecs))); bInDelay = FALSE;
}
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
Wow, thanks a lot... there's lot to learn out there, i guess... :)