Activity timers



Could someone pls tell me why the following code does never
return from the second WaitForSingleObject call !?

HANDLE Active = OpenEvent(EVENT_ALL_ACCESS, FALSE,
TEXT("PowerManager/SystemActivity_Active"));
HANDLE Inactive = OpenEvent(EVENT_ALL_ACCESS, FALSE,
TEXT("PowerManager/SystemActivity_Inactive"));

if (WaitForSingleObject(Inactive, INFINITE) == WAIT_OBJECT_0)
{
if (WaitForSingleObject(Active, INFINITE) == WAIT_OBJECT_0) // <- Stall
forever
{
// Some code
}
}

I'd like to handle Inactive-to-Active transition state using activity
timers but do not understand windows behaviour ... I'm able to
wait for "Inactive" event, howether it stalls inside the second wait for
"Active" event independent from the actual activity on the system.
Any ideas?

Thanks.


.