[Lazarus] Event created by program logic rather than user action
Michael Schnell
mschnell at lumino.de
Mon Nov 9 11:11:14 CET 2015
On 11/08/2015 06:33 PM, Anthony Walter wrote:
>
> 2. If you want to communicate with the user interface, such as
> refreshing the screen based on some calculations, use the Synchronize
> method to do so
If you don't want to have the thread wait for the mainthread to execute
the event, use TThread.Queue (available only as of fpc 3.x) or
Application.QueueAsyncCall
> 3. Do not share data the thread is using in calculations with
> anything. If you need access to the data in somewhere else, use
> Synchronize and make a copy there.
If you want to transfer data from the thread to the main thread and
don't use TThread.Synchronize, you can use a TThreadList to create a
queue of sent data records, or create an object, use a procedure of same
in TThread.Queue or Application.QueueAsyncCall and do "Free;" as the
last instruction of that Procedure (making it a "finalizer")
-Michael
More information about the Lazarus
mailing list