El 27/3/23 a les 11:06, Sven Barth via lazarus ha escrit:
Luca Olivetti via lazarus <lazarus@lists.lazarus-ide.org <mailto:lazarus@lists.lazarus-ide.org>> schrieb am Mo., 27. März 2023, 10:34:

    El 27/3/23 a les 10:13, Jean SUZINEAU via lazarus ha escrit:
     >
     > Le 27/03/2023 à 09:46, Luca Olivetti via lazarus a écrit :
     >> procedure TUpdateThread.Execute;
     >> begin
     >>   while not Terminated do
     >>   begin
     >>     FWaitForm.ShowProgress;
     >>     Sleep(30);
     >>   end;
     >> end;
     >
     > Usually I use TThread.Synchronize to ensure that the graphic code
    is run
     > by the main thread.
     >
     > But it won't work if your main thread is blocking.

    Exactly

     >
     > May be you should do the inverse move the lengthy operation to a
     > separate thread and keep the main thread for the splash screen ?

    Yes, I usually do that, but in this case it's not possible (the lengthy
    operation is just a  TSQLQuery.open that I cannot delegate to a
    different thread).


You need to find a way then, because the GUI handling *must* be done in the main thread.

Opening the query in a thread[*] seems to have no ill effects, so that's what I'm doing now.


[*] 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.

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

Reply via email to