KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Assure the method in EXECUTE ON CLIENT is executed in a new process
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: August 15, 2022

When using the EXECUTE ON CLIENT command, it is recommended to have the method called in a new process. The reasoning for this is to make sure the called method and an eventual UNREGISTER CLIENT are not called within the same process and blocks UNREGISTER CLIENT until the called method has finished executing.

Take for example the called method named "testMethod" runs a delay that takes 10 seconds:

1. Client A calls EXECUTE ON CLIENT which executes "testMethod" to client B
2. Client B executes "testMethod" and will take 10 seconds to complete
3. Client B calls UNREGISTER CLIENT
4. Before the 10 seconds has passed, Client A calls EXECUTE ON CLIENT again which executes "testMethod" to client B
5. Client B finishes the 1st call to "testMethod" then runs the 2nd call to "testMethod" since the UNREGISTER CLIENT call could not execute during the 1st call of "testMethod"

To prevent this situation, simply have a method that calls "testMethod" with New process and have EXECUTE ON CLIENT call that method instead. This will assure that UNREGISTER CLIENT will run independently from the EXECUTE ON CLIENT call and prevent further methods being sent to the client.