Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove anonymous methods from TThread Queue

From within a thread I queue events to run in the context of the main thread like this :

TThread.Queue(nil, procedure begin AddDataToChart(SomeData) end);

Now at some point I need to dequeue these events as the component that is addressed in the anonymous method is destroyed and hence should not receive more data. I know that I can dequeue events from the TThread synclist by calling TThread.RemoveQueuedEvents. Unfortunately this seems to only work for Thread methods, but not for queued anonymous methods. So my question is how to remove my anonymous methods from the queue.

like image 840
iamjoosy Avatar asked Dec 06 '25 05:12

iamjoosy


1 Answers

TThread does not expose any way to remove queued anonymous procedures. The only option would be to queue your anonymous procedures using a dedicated TThread object (call the non-class version of TThread.Queue() method on that object, or pass that object as the AThread parameter to the class version of TThread.Queue()), then you can pass that object to the TThread.RemoveQueuedEvents() method that takes a TThread object as input.

like image 151
Remy Lebeau Avatar answered Dec 08 '25 20:12

Remy Lebeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!