If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

Waiting with message loop

//I am writing a program to auto login in a web site. Before making next attempt I have to wait for some time like some
//10 seconds(it is configurable). But during wating UI should not freeze. I wrote code something like this. Here
//event m_hEvent[1]) will be set by another thread after 10 seconds.The problem is UI still freezes some times!
//Any suggestion?
while(1)
{
//m_hEvent[1] will be set by another thread after 10 seconds
dwRet = MsgWaitForMultipleObjects(1, &m_hEvent[1], FALSE, dwMilliseconds, QS_ALLINPUT);
ResetEvent(m_hEvent[1]);

// There is one or more window message available. Dispatch them
while(PeekMessage(&msg,0,0,0,PM_NOREMOVE))
{
// check for unicode window so we call the appropriate functions
BOOL bUnicode = ::IsWindowUnicode(msg.hwnd);
BOOL bRet;