How to wait for multiple work object in threadpool in c++

In my program, I create a number of TP_WORK objects and submitting to threadpool. Here I want to wait for all the work to be finished. I am using VS2010. The following is the workflow of my program:

class CWork
{
//data members

public:
void Process(){cout<<" work processed\n";}
};

static VOID CALLBACK RunCallBack(PTP_CALLBACK_INSTANCE Instance,
PVOID Context,
PTP_WORK Work)
{
CWork &pWork = *((CWork*)Context);
pWork.Process();
return ;
}
int _tmain(int argc, _TCHAR* argv[])
{
PTP_POOL Pool;
TP_CALLBACK_ENVIRON CBE;
PTP_CLEANUP_GROUP CleanupGroup;
TP_WORK *worker;

Pool = CreateThreadpool(NULL);
InitializeThreadpoolEnvironment(&CBE);
CleanupGroup = CreateThreadpoolCleanupGroup();
SetThreadpoolCallbackPool(&CBE, Pool);
SetThreadpoolCallbackCleanupGroup(&CBE, CleanupGroup, NULL);
SetThreadpoolThreadMaximum(Pool, 5);
SetThreadpoolThreadMinimum(Pool, 1);

std::vector<CWork*> WorkGroup;
//In atual program , WorkGroup is filled by the return value of a function call instead of the following block
for(int i=0;i<10;i++)
{
CWork *workobj = new CWork();
WorkGroup.push_back(workobj);
}
//////////////////////////////////////////////

for (int i=0; i<WorkGroup.size(); i++)
{
worker = CreateThreadpoolWork(RunCallBack, (void*) WorkGroup[i], &CBE);
SubmitThreadpoolWork(worker);
}
//Here I want to wait for all the work to be finished.
// WaitForThreadpoolWorkCallbacks(worker,FALSE);
CloseThreadpoolWork(worker);

CloseThreadpoolCleanupGroupMembers(CleanupGroup,
FALSE, NULL);
CloseThreadpoolCleanupGroup(CleanupGroup);
CloseThreadpool(Pool);
return 0;
}

I could not find any API which waits for a list of work objects as does in WaitForMultipleObjects().

Can anyone help me to wait for multiple work objects in the above case or suggest me a better design if my design is wrong so that I can handle multiple objects wait.

Note: Creating event and wait for the events to signal is under my consideration.Please advice me.
Topic archived. No new replies allowed.