Everhart, Glenn From: Brian Kowald [bkowald@tiltrac.com] Sent: Friday, January 22, 1999 12:16 PM To: ntdev@atria.com Subject: Re: [ntdev] Multithreaded Issue Here is the proper way to wait for a thread to terminate: // declaration of thread pointer CWinThread *m_LoaderThread; // thread object // starting the thread: m_LoaderThread = AfxBeginThread(LoaderThreadFunc, (LPVOID)this, // pointer to this class THREAD_PRIORITY_NORMAL, 0, // stacksize 0, // create flags NULL); // security // waiting for the thread to stop HANDLE hThread = m_LoaderThread->m_hThread; if (::WaitForSingleObject (hThread, 5000L) == WAIT_TIMEOUT) { theApp.AddToLog("LOADER thread thread did not terminate"); } You could get the handles to more than one thread and use WaitForMultiple... if you wanted to. Brian -----Original Message----- From: Nathan Nesbit To: 'Casey, Chance' ; ntdev@atria.com Date: Thursday, January 21, 1999 10:31 PM Subject: RE: [ntdev] Multithreaded Issue >According to the docuementation AfxBeginThread returns a CWinThread* not a >HANDLE. That might be a good place to start. > > >Nathan Nesbit >Software Design Engineer >NT Core Test > > >-----Original Message----- >From: Casey, Chance [mailto:CCasey@coair.com] >Sent: Thursday, January 21, 1999 3:58 PM >To: ntdev@atria.com >Subject: [ntdev] Multithreaded Issue > > >I'm creating worker threads but need to wait for them all to >finish before continuing on in the code. This is what I've >tried, but it doesn't seem to work (not waiting) > >int intarray[17]; >HANDLE handlearray[16]; >for(int i=1;i<=16;i++) >{ > intarray[i]=i; > handlearray[i-1]= > AfxBeginThread(TestFlifo, reinterpret_cast(intarray[i])); >} > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]