The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

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[WayBackGetThreadId 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): [WayBackCurrentThread.

The latest version of Delphi, Delphi 2009, has a CurrentThread class property on the TThread 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 – [WayBackBarry Kelly

Sources

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.