On Mon, 27 Mar 2023, Luca Olivetti via lazarus wrote:

El 27/3/23 a les 11:59, Luca Olivetti via lazarus ha escrit:

[*] instead of opening the query I spawn a thread that opens it, wait for it to finish while executing Application.ProcessMessages and eventually reraise the exception that was generated inside the thread.


Speaking of which, I encapsulated it in a procedure (TWaitForm is the spash screen, Aproc is a procedure of object, TExecInThread simply calls AProc in its execute method):

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;

Ehm. In case of an exception, ut will never be freed ?

Michael.
--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to