?
Solved

AfxBeginThread and Thread ID

Posted on 2006-04-05
5
Medium Priority
?
1,139 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:mrwad99
  • 2
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16379634
AfxBeginThread returns CWinThread*. CWinThread::m_nThreadID is thread ID.
0
 
LVL 19

Author Comment

by:mrwad99
ID: 16379697
Thanks.  And I can rely on the fact that each thread will have a *completely unique* ID, yes ?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16379770
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
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16380265
<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
 
LVL 19

Author Comment

by:mrwad99
ID: 16380762
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question