Hello,

my question is about using the TThread.Synchronize, Queue and ForceQueue 
methods. Unfortunately, the parameter they take is of type TThreadMethods which 
allows calling only methods having no parameters at all. I assume this is done 
to simplify the implementation on client-side but causes headaches on my side :)

Delphi solves the issue with having anonymous methods which aren't yet 
available in FPC yet. So unfortunately I cannot do something like 
TThread.Synchronize(NIL, @procedure(a,b,c)).

As far as I have seen so far, the common solution is to use a variable inside 
the class to cache the parameters, then to use a DoCallSync procedure which 
takes no parameters but can use the cached values inside, and finally to call 
TThread.Synchronize(NIL, @DoCallSync). I have stick to this concept when using 
Synchronize, too.

But what is the correct way to deal with ForceQueue? I think I cannot use a 
global variable for this case because its value could be overwritten between 
the call to ForceQueue and the moment the queued method is actually being run. 
Do I have to use a FIFO-buffer for this purpose? And if yes, would it be safe 
(in the sense of getting no deadlock situations) to use a TThreadList for that?

Kind regards,
Thomas

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to