AfxBeginThread and Thread ID

Ah hello.

I am creating a thread via AfxBeginThread, and I would like to know how I can get hold of the ID of the thread.  I can obviously assign some data structure to the thread that contains some identifier, but I would like to know the correct way to get the ID.

Any ideas ?

TIA
LVL 19
mrwad99Asked:
Who is Participating?
 
AlexFMCommented:
AfxBeginThread returns CWinThread*. CWinThread::m_nThreadID is thread ID.
0
 
mrwad99Author Commented:
Thanks.  And I can rely on the fact that each thread will have a *completely unique* ID, yes ?
0
 
AlexFMCommented:
Every thread has unique ID among currrently running threads. Otherwise OpenThread API could open wrong thread.
I don't know whether created thread ID can be equal to ID of thread which finished some time before.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
<I don't know whether created thread ID can be equal to ID of thread which finished some time before.>

I suspect it *could* be - Why should windows need to keep track of non-existant threads?
0
 
mrwad99Author Commented:
Thanks AlexFM.  Andy: interesting, worth keeping in mind.

If anyone is interested, I have a stinker of a problem at http:Q_21802368.html on a similar slant to this one
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.