Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > getting the handle for a thread

Reply
Thread Tools

getting the handle for a thread

 
 
PaulH
Guest
Posts: n/a
 
      09-25-2006
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(???);
}

 
Reply With Quote
 
 
 
 
Noah Roberts
Guest
Posts: n/a
 
      09-25-2006

PaulH wrote:
> 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?


All of the above is platform specific. You need to ask these questions
in a newsgroup that's subject includes the platform or library you are
using for threading.

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      09-25-2006
PaulH wrote:
> 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?


It seems that you're in a wrong newsgroup. None of the functions you
mention exist in standard C++ language, the topic of this newsgroup.
Perhaps you need to visit 'comp.os.ms-windows.programmer.win32' or some
such...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Package to handle table text render (handle space or tab betweenthe columns) ? =?ISO-8859-1?Q?KLEIN_St=E9phane?= Python 3 10-06-2006 08:46 AM
how to handle exception in a second thread in asp.net? lucy ASP .Net 2 11-03-2005 02:58 PM
Possible to handle web requests without an ASPX page? i.e. have DLL handle request. jdlwright@shaw.ca ASP .Net 2 05-31-2005 05:42 PM
how to handle command line output(not terminal handle) Leon Python 2 11-04-2004 05:16 AM
File Handle Reading Blues: Rereading a File Handle for Input Dietrich Perl 1 07-22-2004 10:02 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57