WaitForMultipleObjects And notifying
-
Hello I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes. The event is used to signal my workerthread when some new data should be sent. In the workerthread I wait for some diffrent events: hEvents[0] = pTP->hStopEvent; hEvents[1] = pTP->hNewDataEvent; hEvents[2] = osWriter.hEvent; hEvents[3] = osReader.hEvent; hEvents[4] = hDoReadEvent; pTP is a point to a struct that is passed to the thread when I create it. My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help. The class is a socket communication class..
-
Hello I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes. The event is used to signal my workerthread when some new data should be sent. In the workerthread I wait for some diffrent events: hEvents[0] = pTP->hStopEvent; hEvents[1] = pTP->hNewDataEvent; hEvents[2] = osWriter.hEvent; hEvents[3] = osReader.hEvent; hEvents[4] = hDoReadEvent; pTP is a point to a struct that is passed to the thread when I create it. My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help. The class is a socket communication class..
-
What do you mean "only detects that signal state randomly?" WaitForMultipleObject signals "Either any one or all of the specified objects are in the signaled state" according to MSDN. Kuphryn
-
WaitForMultipleObjects wait for any of the events to get signalled. But it only works sometimes when I signals the hNewDataEvent, i want to know why. The event is created with the GUI thread and is passed to the workerthread when I create it.
-
It still would not become signaled even when you sign one or other events? Make sure the other handles are valid. Kuphryn
-
Hello I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes. The event is used to signal my workerthread when some new data should be sent. In the workerthread I wait for some diffrent events: hEvents[0] = pTP->hStopEvent; hEvents[1] = pTP->hNewDataEvent; hEvents[2] = osWriter.hEvent; hEvents[3] = osReader.hEvent; hEvents[4] = hDoReadEvent; pTP is a point to a struct that is passed to the thread when I create it. My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help. The class is a socket communication class..
so you have something like the below snippet? ret = WaitForMultipleObject( 5, hEvents, FALSE, INFINITE ); if (ret == (WAIT_OBJECT_0 + 1)) //dosomething the key points here are: 1) passing FALSE so that it doesn't have to wait for all objects 2) using INFINITE so that it blocks until an event is signalled and won't timeout, and 3) correctly determining which has become signalled. Since you didn't provide any code I can't really say what's the problem. Joel Lucsy
-
so you have something like the below snippet? ret = WaitForMultipleObject( 5, hEvents, FALSE, INFINITE ); if (ret == (WAIT_OBJECT_0 + 1)) //dosomething the key points here are: 1) passing FALSE so that it doesn't have to wait for all objects 2) using INFINITE so that it blocks until an event is signalled and won't timeout, and 3) correctly determining which has become signalled. Since you didn't provide any code I can't really say what's the problem. Joel Lucsy