[python-win32] Getting new thread's ID (not handle)

Mark Hammond mhammond at skippinet.com.au
Tue Aug 2 00:28:13 CEST 2005


GetThreadID is a member of an MFC CThread class, probably not what you want.
The thread itself can call GetCurrentlThreadId - so the simplest way is
probably for your new thread to call this function and store the result in a
global.  Your main thread can then use this global.

The only other way I know to get this thread ID is to create the thread
using win32process.CreateThread - that will return the thread ID and handle
of the new thread.

Mark
  -----Original Message-----
  From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Justin Johnson
  Sent: Tuesday, 2 August 2005 5:35 AM
  To: python-win32 at python.org
  Subject: [python-win32] Getting new thread's ID (not handle)


  MSDN says PostThreadMessage takes the thread ID as a parameter.  >From
reading the doc I see that handle and ID are different and that both should
be returned when creating a new thread with CreateThread.  I am creating a
new thread with the threading module and do not see a way to get the ID
back.  I searched the source to see if CreateThread is being called and
didn't find anything.  Does anyone know how to get a thread's ID if the
thread was created with threading.Thread?

  Thanks.
  Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050802/c61130b2/attachment.htm


More information about the Python-win32 mailing list