Timer and Event
Hi,
I would like your opinion about the best way of solving a problem.
Here is my situation, I have a DLL with some exported functions and a
hidden window receiving some messages from a COM object.
I have one method that we 'll call CalculateEnd() define like this :
void Foo::CalculateEnd( ULONG a_ulErrorCode )
{
m_bfActive = FALSE;
MYTRACE0(0, "--->BEFORE DELAY\n" );
// HERE I MUST DO A NON BLOCKING WAIT during 1800ms.
// IF I don't have received a signal from the window proc at the end
// of the timeout I keep on executing program, otherwise I still wait
// 1800ms
MYTRACE0(0, "--->AFTER DELAY\n" );
m_bActive = TRUE;
}
and my window proc :
LRESULT CALLBACK Foo::WndNotifierProc( HWND hWnd, UINT nMsg, WPARAM
wParam, LPARAM lParam )
{
LRESULT lResult = TRUE;
BOOL l_bNotify = FALSE;
switch( nMsg )
{
case MESSAGE1:
case MESSAGE2:
case MESSAGE3:
break;
default:
lResult = DefWindowProc( hWnd, nMsg, wParam, lParam );
break;
}
if (bNotify == TRUE)
{
// NOTIFY CalculateEnd
}
return lResult ;
}
When I exit from CalculateEnd I am not supposed to received MESSAGES so
I am doing a non blocking wait.
Of course I have thought about
::WaitForSingleObject/MsgWaitForMultipleObjects but I don't see how to
restart the 1800 ms timer.
The philosophy here is to say, as long as I received notifs I wait and
if I don't receive a notif during 1800ms it means that I can go on.