[fpc-pascal] TThread.Queue vs TThread.Synchronize

Michael Schnell mschnell at lumino.de
Tue Feb 24 10:44:02 CET 2015

On 02/23/2015 06:58 PM, Graeme Geldenhuys wrote:
> Continuing on the TThread.Queue subject - is there any way to pass
> parameters (or record structure with basic types) to the Queue() call?
On this behalf, "Application.QueuAsyncCall" is more versatile.

But it's easy with TThread.Queue, as well.

  - define  a class (not to be derived from TThread) that holds the data 
to be transferred and a procedure without parameters
  - create an instance of that class
  - use TThread.Queue to have the said procedure be executed by the main 
  - at the end of the said procedure do "free" (without a prefix) this 
will make the instance remoce itself.


> I understand that anonymous methods (something I again don't know much
> about) take a snapshot of local variables. So that could possibly be
> used with TThread.Queue() to send variable (simple data types)
> information? Please correct my if I am wrong - like I said, I don't
> really know anonymous methods or their real usage.

The algorithm above is just an anonymous method that simply is not 
anonymous but "named" in the usual way classes work.


More information about the fpc-pascal mailing list