The WaitForMultipleObjects() function does not work correctly together with pseudohandles in Windows XP, in Windows Server 2003, or in Windows Vista.

Consider the following sample code.

int _tmain(int argc, _TCHAR* argv[])
      HANDLE hnd[1]; 
	long res; 
	hnd[0] = GetCurrentProcess(); 

        res = WaitForMultipleObjects(1, hnd, FALSE, 3000);
      return 0;

After you run the sample code, you expect the function to return after three seconds. However, it returns a “WAIT_FAILED” error, and it does not wait.

Leave a Reply