DWORD WaitForMultipleObjects(DWORD nCount, const
HANDLE* lpHandles,
BOOL
bWaitAll, DWORD dwMilliseconds)
{
PENCAP_EVENT *eventPointerArray =
(PENCAP_EVENT *)lpHandles;
CFRunLoopRef curRunLoop =
CFRunLoopGetCurrent();
int cnt;
for(cnt = 0; cnt < nCount;
cnt++) {
CFRunLoopAddSource(curRunLoop,
eventPointerArray[cnt]->source,
kCFRunLoopCommonModes);
}
// Run the CFRunLoop
kCFRunLoopDefaultMode
SInt32 result =
CFRunLoopRunInMode(kCFRunLoopDefaultMode, (dwMilliseconds/1000),
true);
// Remove RunLoopSource
for(cnt = 0; cnt <
nCount; cnt++) {
CFRunLoopRemoveSource(curRunLoop,
eventPointerArray[cnt]->source,
kCFRunLoopCommonModes);
}
if(result == kCFRunLoopRunTimedOut)
{
// timeout
return
WAIT_TIMEOUT;
}
if(result != kCFRunLoopRunHandledSource)
{
// wait failed
return
WAIT_FAILED;
}
/////////////////////////////////////////////// the following code here has
no effect