El 27/3/23 a les 15:40, Mattias Gaertner via lazarus ha escrit:
procedure ExecWithSplash(AProc:TThreadProc);
var wf:TWaitForm;
ut:TExecInThread;
begin
Wf:=TWaitForm.Create(Application);
WF.Show;
ut:=TExecInThread.create(AProc);
while not ut.Finished
Application.ProcessMessages
wf.free;
if ut.FatalException<>nil then
raise(ut.FatalException);
ut.free;
end;
The problem here is, if AProc raises an exception, I cannot free the
thread causing a leak.
What does TExecInThread.Execute do?
As I said, it just calls AProc (which the constructor stored in FProc)
procedure TExecInThread.Execute;
begin
FProc()
end;
constructor TExecInThread.create(AProc:TThreadProc);
begin
FProc:=AProc;
inherited create(false);
end;
Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007
--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus