GetThreadID()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

GetThreadID()

Post by Tranquil »

Maybe there is a way to get this ID on another way (or I'm miss an existing command) but I'm searching for a way to get the PB internal ThreadID of a running thread itself like this:

Code: Select all

Procedure MyThread(Var.l)
  Debug GetThreadID()
EndProcedure

Debug CreateThread(@MyThread(),0)

So that both debugs gives the same results.
Tranquil
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Post by Poshu »

why don't you use a global var to stock your ThreadID? You can read it from anywhere this way...
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Hi,

Theare are OS/framework dependent functions for this.

Code: Select all

; Windows
Procedure ImAThread (blub)
   Debug GetCurrentThread_()
EndProcedure

; Linux (SDL)
Procedure ImAThread (blub)
   Debug SDL_ThreadID_()
EndProcedure
Maybe you could use it while this function isn't implemented in PB.

Best regards
Wolf
Post Reply