DWORD WaitForSingleObject( HANDLE hHandle, // handle of object to wait for DWORD dwMilliseconds // time-out interval in milliseconds ); ParametershHandleIdentifies the object. For a list of the object types whose handles can be specified, see the following Res section. Windows NT: The handle must have SYNCHRONIZE access. For more information, see Access Masks and Access Rights. dwMillisecondsSpecifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
Thread2: sleep(1hour) then interrupt Thread1;
for(int i=0;i<24;i++) //24个5分钟是二小时
{
Thread.Sleep(5min);
if(someFlag==true)break;
}
DWORD dwMilliseconds // time-out interval in milliseconds
);
ParametershHandleIdentifies the object. For a list of the object types whose handles can be specified, see the following Res section.
Windows NT: The handle must have SYNCHRONIZE access. For more information, see Access Masks and Access Rights. dwMillisecondsSpecifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.