On 17.06.2017 22:25, el es via Lazarus wrote:
Where does the call queued from a thread, return to ?
From the POV of the application programmer: "nowhere". it's just
another (main-Thread-) "Event" that (like "OnClick") gets "fired" by the
Lazarus/fpc infrastructure and is done.
The object's lifetime is controlled by the dedicated thread
(meaning only one thread is allowed to Free() it);
Of course a queued event should not use an object that might get freed
by other means.
If you want to pass data to the event, a useful way to avoid this is to
create a transfer object:
Type TTransfer = class; procedure the_event; TData: the_data; .....
running in the WorkerThread:
Transfer := TTransfer.Create(...)
Transfer.the_data. ..... := ....
queue(@Transfer.the_event);
(no Transfer.Free in the thread !!!)
running in the MainThread:
procedure TTransfer.the_event()
begin
...
fetch something from the_data
...
Free; (this is Actually Self.Free; )
end;
-Michael
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus-ide.org/listinfo/lazarus