redspider
April 10th, 2006, 10:22 PM
vector<HANDLE> hThread(id);
....
WaitForMultipleObjects(id, hThread, TRUE, INFINITE);
error C2664: 'WaitForMultipleObjects' : cannot convert parameter 2 from 'std::vector<_Ty>' to 'const HANDLE *'
How can i fix this ?
kuphryn
April 10th, 2006, 11:40 PM
One solution is array.
dynamic allocation
Kuphryn
Arjay
April 11th, 2006, 09:08 AM
vector<HANDLE> hThread(id);
....
WaitForMultipleObjects(id, hThread, TRUE, INFINITE);
error C2664: 'WaitForMultipleObjects' : cannot convert parameter 2 from 'std::vector<_Ty>' to 'const HANDLE *'
How can i fix this ?You have a couple of typo's. Try...
#include "stdafx.h"
#include "vector"
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<HANDLE> vEvents;
HANDLE hEvent1 = CreateEvent( NULL, TRUE, FALSE, NULL );
HANDLE hEvent2 = CreateEvent( NULL, TRUE, TRUE, NULL );
vEvents.push_back( hEvent1 );
vEvents.push_back( hEvent2 );
switch(WaitForMultipleObjects(
static_cast<DWORD>(vEvents.size()),
&vEvents[0],
FALSE,
5000) )
{
case WAIT_OBJECT_0:
break;
case WAIT_OBJECT_0 + 1:
break;
case WAIT_TIMEOUT:
break;
default:
DWORD dwError = GetLastError();
}
return 0;
}
Btw, I used events because it was easy to code, but thread handles (or any other sync object) is the same.
redspider
April 11th, 2006, 08:58 PM
Thank you.