rtl/objpas/classes/classes.inc has function CheckSynchronize(timeout : longint=0) : boolean;
I find it curious that the function always returns false.
function CheckSynchronize(timeout : longint=0) : boolean;
{ assumes being called from GUI thread }
var
ExceptObj: TObject;
tmpentry: TThread.PThreadQueueEntry;
begin
result:=false;
{ first sanity check }
if Not IsMultiThread then
Exit
{$ifdef FPC_HAS_FEATURE_THREADING}
{ second sanity check }
else if GetCurrentThreadID<>MainThreadID then
raise EThread.CreateFmt(SCheckSynchronizeError,[GetCurrentThreadID]);
if timeout>0 then
RtlEventWaitFor(SynchronizeTimeoutEvent,timeout)
else
RtlEventResetEvent(SynchronizeTimeoutEvent);
tmpentry := PopThreadQueueHead;
while Assigned(tmpentry) do
begin
{ step 2: execute the method }
exceptobj := Nil;
try
ExecuteThreadQueueEntry(tmpentry);
except
exceptobj := TObject(AcquireExceptionObject);
end;
{ step 3: error handling and cleanup }
if Assigned(tmpentry^.SyncEvent) then
begin
{ for Synchronize entries we pass back the Exception and trigger
the event that Synchronize waits in }
tmpentry^.Exception := exceptobj;
RtlEventSetEvent(tmpentry^.SyncEvent)
end
else
begin
{ for Queue entries we dispose the entry and raise the exception }
Dispose(tmpentry);
if Assigned(exceptobj) then
raise exceptobj;
end;
tmpentry := PopThreadQueueHead;
end
{$endif};
end;