[fpc-devel] Suspicion about TThread.Synchronize

Martin Frb lazarus at mfriebe.de
Thu Feb 7 00:10:24 CET 2019


On 06/02/2019 23:38, Luca Olivetti wrote:
>
> and the exception logged (though the logging in turn uses synchronize).

What OS?

On Windows you can use  LazLogger.  (in Laz 2.0.0)
It uses TThread.Queue by default, but you can replace 
TLazLoggerFileHandleMainThread with TLazLoggerFileHandleThreadSave
in

function TLazLoggerFile.GetFileHandle: TLazLoggerFileHandle;
begin
   if FFileHandle = nil then
     FFileHandle := TLazLoggerFileHandleMainThread.Create;
   Result := FFileHandle;
end;

That means that writeln is called in the same thread. (works (at least) 
on windows, but make sure the handle is opened by the main thread, or it 
will be closed by whatever thread did open it, when that thread exits).




More information about the fpc-devel mailing list