Reputation: 160
I'm coding a program in C++ in Visual Studio 19 that waits for 640 events to happen (in its case, it's just a array of 640 HANDLE where every position needs to move right or left, that is not important).
Well, everyone of those has been initialised as
for(i=0; i<640; i++)
vector[i]=CreateEvent(NULL, true, false, NULL);
The issue with this is that the most important thread is the one who waits to all the events to happen, and I do:
WaitForMultipleObjects(640, vector, TRUE, INFINITE);
And I have the capital problem that my code just skips that line for some reason. Is there anyone who may tell me what's happening or give me an alternative solution?
Upvotes: 0
Views: 62
Reputation: 32727
According to the docs for WaitForMultipleObjects
, the maximum number of handles that can be waited on is given by MAXIMUM_WAIT_OBJECTS
. A search of the Windows header files shows that it is defined as
#define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects
in WinNT.h
. So you're waiting on too many objects.
Since you want to wait for all of them, you could try breaking your request down into small, manageable sized chunks.
Upvotes: 3