From 49100cc42ba9d0af33afb711e5d4478a204927e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Mon, 15 Jan 2024 14:19:42 +0100 Subject: [PATCH] * Add Current and CurrentIsMain --- rtl/objpas/classes/classes.inc | 7 +++++++ rtl/objpas/classes/classesh.inc | 2 ++ 2 files changed, 9 insertions(+) diff --git a/rtl/objpas/classes/classes.inc b/rtl/objpas/classes/classes.inc index 1b7324da2a..eae712a38d 100644 --- a/rtl/objpas/classes/classes.inc +++ b/rtl/objpas/classes/classes.inc @@ -434,6 +434,13 @@ procedure TThread.DoneSynchronizeEvent; end; + +class function TThread.CurrentIsMain : Boolean; + +begin + Result:=TThread.Current.ThreadID=MainThreadID; +end; + class procedure TThread.Synchronize(AThread: TThread; AMethod: TThreadMethod); var syncentry: PThreadQueueEntry; diff --git a/rtl/objpas/classes/classesh.inc b/rtl/objpas/classes/classesh.inc index ba916e5ac8..99c5b8bf02 100644 --- a/rtl/objpas/classes/classesh.inc +++ b/rtl/objpas/classes/classesh.inc @@ -2328,7 +2328,9 @@ type procedure Suspend; deprecated; procedure Terminate; function WaitFor: Integer; + class function CurrentIsMain : Boolean; static; inline; class property CurrentThread: TThread read GetCurrentThread; + class property Current: TThread read GetCurrentThread; class property ProcessorCount: LongWord read FProcessorCount; class property IsSingleProcessor: Boolean read GetIsSingleProcessor; property FreeOnTerminate: Boolean read FFreeOnTerminate write FFreeOnTerminate;