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";}
};
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);
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.