The loop above does overwrite your vars,
so you will not can to reference the created threads...
How do you use the function WaitForMultipleObjects(..) exactly ? :)
sksksksksksksks wrote:
Is there any other method to assign the child thread variables that are not fixed and will depends on runtime...
How many threads do you need ?
If they are two only then you do not need the loop :)
Assumed your vars are valid:
void CYourDialog::EndWorkers()
{
m_bExitThreads = true;
if (m_Thread[0] && m_Thread[1]) {
HANDLE hThreads[2] = {
m_Thread[0]->m_hThread,
m_Thread[1]->m_hThread
};
WaitForMultipleObjects(2,
hThreads,
TRUE,
INFINITE);
m_Thread[0] = m_Thread[1] = NULL;
}
}