I totally forgot that Delphi has had a function to get the current executing thread – Stack Overflow
Posted by jpluimers on 2018/07/05
While updating some old code fiddling with the[WayBack] GetThreadId function, I wanted to have some TThread wrapper around it. I had totally forgotten there has been already a means for this since Delphi 2009 (which initially had a bug, but that was worked around at first and fixed later): [WayBack] CurrentThread.
The latest version of Delphi, Delphi 2009, has a
CurrentThread
class property on theTThread
class.This will return the proper Delphi thread object if it’s a native thread. If the thread is an “alien” thread, i.e. created using some other mechanism or on a callback from a third party thread, then it will create a wrapper thread around the thread handle.
20081001 at 5:00 – [WayBack] Barry Kelly
Sources
- [WayBack] multithreading – Is there a function in Delphi to get the current executing thread? – Stack Overflow
- [WayBack] Delphi TThread.CurrentThread and EAccessViolation – Is This a Bug or My Incompetence..? – Stack Overflow
- [WayBack] QualityCentral 67726 – AV on closing after calling CurrentThread
–jeroen
Leave a Reply