Hello Everyone!
Function WaitForMultipleObjects
Requirements:
Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
But this function doesn't work in WinNT.
Why
Thanks in advance
Vladimir

WaitForMultipleObjects doesn't work
Ruhina
LARGE_INTEGER check_elapse = {-10000};
check_elapse now is not a NEGATIVE. Becase, only low dword wich is unsigned filled with 0xfff..., the high dword is still being filled with zero. Its mean a number is positive.
To make check_elapse negative, use this code
check_elapse.QuadPart=-100000000;
Moreove, its doesn't metter in this example value of this varible, the timer is periodic.
lChekPeriod = 1000;
//1000Its mean after check_elapse time the timer will be in signal state every second.
Code works fine in XP.
Manubhaskar
Maybe you should replace this:
with this:
Otherwise the second argument of SetWaitableTimer is treated as an absolute time value, which is never reached, since it is in the past (1/1/1601).
I hope this helps.
Ronaldlee Ejalu
Can you give us GetLastError after:
CreateWaitableTimer
SetWaitableTimer
And return results of this functions.
Are you sure, that
CHECK_PERIOD == 1000
May be it's zero.
DanParks
So by returns nothing, you actually mean that it doesn't return at all In this case, the problem is that you are never properly signaling either of the objects in the hControl structure.
anubisascends
Thore
yes, CHECK_PERIOD == 1000,
I defined it:
#define
CHECK_PERIOD 1000Ioanna
aboeing
GetLastError after CreateWaitableTimer and SetWaitableTimer returns 0.
And, as I already told, in WinXp everything is fine, code works, but in WinNT I have problems and can not understand, why
r.matteja
Muzzzy
In WinXP SP2 everything is ok,
but in WinNT nothing happens:
I cannot receive a code of return at all. Function WaitForMultipleObjects returns nothing.
MickBeth
Now I'm using LARGE_INTEGER check_elapse = {-10000};
When I try to receive a return code (just for test)
while (1){
printf("step 1");
dwObject = WaitForMultipleObjects(dwCount, hControl, FALSE, INFINITE);
//1printf("dwObject = %d", dwObject);
printf("step 2");
...
I receive the following
step 1
and that's all:)
newindotnet
HeathM
Are you sure, that
CHECK_PERIOD == 1000
May be it's zero.
Try to set 1000 manualy.
Vaish
So, fragment of a code from the program
HANDLE hGlobalStop;
HANDLE hCheckTimer;
SHORT ReadStatus()
{
hGlobalStop = CreateEvent(NULL, FALSE, FALSE, NULL);hCheckTimer = ::CreateWaitableTimer(NULL, FALSE, NULL);
if (( hCheckTimer ) && ( hGlobalStop )){
lChekPeriod = CHECK_PERIOD; //1000::SetWaitableTimer(hCheckTimer, &check_elapse, lChekPeriod, NULL, NULL, FALSE);
DWORD dwThreadId;
HANDLE hThread;
// no security attributes0,
// use default stack size(LPTHREAD_START_ROUTINE)ThreadFunc,
// thread function&hCheckTimer,
// argument to thread function0,
// use default creation flags&dwThreadId);
// returns the thread identifier if (hThread == NULL){//error}
::CancelWaitableTimer(hCheckTimer);
::CloseHandle(hCheckTimer);
}
} VOID WINAPI ThreadFunc(LPVOID lpParam){
DWORD dwCount = sizeof(hControl) / sizeof(HANDLE);DWORD dwObject = 0;
//this code doesn't work at all :
//WaitForMultipleObjects returns nothing in WinNT
while (WAIT_FAILED != (dwObject = WaitForMultipleObjects(dwCount, hControl, FALSE, INFINITE))) //1
{
switch (dwObject){
//STOP case WAIT_OBJECT_0:case (WAIT_OBJECT_0 + 1):
// An error occurred.
default:}
}
ExitThread(0);
}