Search code examples
delphifiremonkey

how to report the execution on a task to next processmessage?


I don't want to execute the current instructions in the current processmessage loop, but instead execute it in the next processmessage loop. Is their a good way to do it ? TThread.queue seam to be what i m looking for except that TThread.queue can not be executed from the main Thread :( I m under firemonkey also if it's matter


Solution

  • TThread.Queue() is asynchronous only if it is called in a worker thread. When TThread.Queue() is called in the main thread, it is synchronous instead 1.

    To do what you are asking for, you can use TThread.CreateAnonymousThread() or TTask.Run() to create a worker thread that then calls TThread.Queue().

    1: please vote on RSP-15427 Add an option to let TThread.Queue() run asynchronously when called by the main UI thread.