Page 1 of 1

GetThreadID()

Posted: Sun Feb 03, 2008 12:45 am
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.

Posted: Wed Feb 06, 2008 3:40 am
by Poshu
why don't you use a global var to stock your ThreadID? You can read it from anywhere this way...

Posted: Wed Feb 06, 2008 12:20 pm
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