I want to use MultiThreading within TMS Scripter. How can I create and use threads inside the Scripter? Is there an example of its usage?
TatScripter component itself is not thread-safe.
You can use execute a script using TatScripter from a thread, as long as you use the TatScripter object only from a single thread. To use multi-thread, you create one TatScripter component for each thread.
Check the multithread demo in demos folder. It shows how to use TMS Scripter with multiple threads.
Hello Wagner,
I read the TMS Scripter User Guide, which states that TatScripter is thread-safe, while your response suggests otherwise. Could you clarify whether it is actually thread-safe?
My primary issue was that adding a REST Debugger at runtime caused my FMX Scripter project to freeze when making a request. I resolved this by using ExecAsync, which, according to the documentation, executes the request in a separate thread.
This brings up a related question:
- Since ExecAsync uses threading without issues, is there an official way to execute scripts in a separate thread to prevent the UI from freezing?
- Would creating a dedicated TatScripter instance per thread be a valid solution for handling long-running scripts asynchronously?
Looking forward to your clarification.
Best regards.
Well, "thread-safe" can be interpreted in different ways. What we meant in the documentation is that the scripter can be used from threads. But you can't use the same component from multiple threads.
You can check the "threads" demo in TMS Scripter distribution. The way is to create a scripter component, execute it, and destroy it, all from the same thread.
Yes.