Re: Question about WaitForSingleObject() ?

From: Michael J. Salamone (mikesa#at#entrek#dot#com)
Date: 02/24/05


Date: Thu, 24 Feb 2005 03:32:34 -0800

Well, we know that nothing happens "at the same time".

It doesn't really matter which return code you get, does it? If the
function return indicates timeout, take your timeout path. In your timeout
path, you can still query if the event is set or not (call
WaitForSingleObject again, with 0 for timeout). Many times, this function
is run in the loop. So, you'd pick up the object signaled state on the next
iteration of the loop.

-- 
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"Knight Lin" <lhbb5405@hotmail.com> wrote in message 
news:O6FTeHlGFHA.2752@TK2MSFTNGP12.phx.gbl...
> Hi all:
>
>    As we know, function  WaitForSingleObject(HANDLE hHandle, DWORD 
> dwMilliseconds ) returns when the specified object(hHandle) is in the 
> signaled state or when the time-out(dwMilliseconds ) interval elapses. 
> But,if the system is busy,then the object is signaled and time-out elapses 
> at the same time,so which return-value will be 
> returned,WAIT_OBJECT_0(object is signaled) or WAIT_TIMEOUT(time-out 
> interval elapsed, and the object's state is nonsignaled) ?
>
>
> --------------
> Knight Lin
> 


Relevant Pages

  • Re: query the state of a global
    ... WaitForSingleObject() with a timeout of 0, then check the return value to ... event in the signaled state. ...
    (microsoft.public.vc.mfc)
  • Question about WaitForSingleObject() ?
    ... dwMilliseconds) returns when the specified objectis in the ... signaled state or when the time-outinterval elapses. ... Knight Lin ...
    (microsoft.public.windowsce.platbuilder)