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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With