P
PaulH
I have a bunch of threads created with CreateThread(). When each thread
is exiting, it posts a message saying that it's about to quit. I'd like
to do the CloseHandle() on the thread handle in that message handler.
But, how can I tell which handle is the one for that particular thread
which just finished? Is there a call like GetThreadHandle() I can use
from within the thread to pass back the same handle I got from
CreateThread() to the message-handler?
Thanks,
PaulH
std::vector<HANDLE> m_vThreads;
CMyDlg::StartAThread()
{
THREAD_INFO *pTI = new THREAD_INFO
/*...*/
m_vThreads.push_back(AtlCreateThread(MyThread, pTI);
}
static DWORD __stdcall MyThread(THREAD *pTI)
{
std::auto_ptr<THREAD> pATI(pTI);
/*...*/
PostMessage(pATTI->hWnd, UWM_FINISHED_TEST, 0, 0);
return 0;
};
CMyDlg::OnFinishedThread(/*...*/, WPARAM wParam, LPARAM lParam)
{
CloseHandle(???);
}
is exiting, it posts a message saying that it's about to quit. I'd like
to do the CloseHandle() on the thread handle in that message handler.
But, how can I tell which handle is the one for that particular thread
which just finished? Is there a call like GetThreadHandle() I can use
from within the thread to pass back the same handle I got from
CreateThread() to the message-handler?
Thanks,
PaulH
std::vector<HANDLE> m_vThreads;
CMyDlg::StartAThread()
{
THREAD_INFO *pTI = new THREAD_INFO
/*...*/
m_vThreads.push_back(AtlCreateThread(MyThread, pTI);
}
static DWORD __stdcall MyThread(THREAD *pTI)
{
std::auto_ptr<THREAD> pATI(pTI);
/*...*/
PostMessage(pATTI->hWnd, UWM_FINISHED_TEST, 0, 0);
return 0;
};
CMyDlg::OnFinishedThread(/*...*/, WPARAM wParam, LPARAM lParam)
{
CloseHandle(???);
}