Just wondering if anyone can help with this.
I'm writing an app that involves the user being able to start variuos commands, each of which starts a new thread. So i have an array of threads. Then every second i call WaitForMultipleObjects(num_threads, thread_handles_arr, FALSE, 0) and analyse the return value. (I dont wait on each thread to finish using INFINITE because the system needs to be usable all the time and not hanging on one thread).
This is fine for just one thread, but with more than one, it returns zero (WAIT_OBJECT_0) when the 0th element has become signalled, and from each second onwards just returns "ERROR_INVALID_HANDLE". Even though some of the other handles higher in the array havent become signalled.
Is it true that ERROR_INVALID_HANDLE is returned if at least one of the handles in the array is invalid ? Or am i imagining that ? I know that WaitForMultipleObjects returns the lowest element in the array that's become signalled, but what about the after that ?