KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4D.HTTPRequest .wait() yields execution time to other worker messages in queue
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: November 11, 2024

Similar to the .wait() function for 4D.SystemWorker, when using .wait() on an instance of 4D.HTTPRequest, note that it yields execution time to execute other worker messages in the queue. For example, consider the following calls:

CALL WORKER("MyProcess"; "MakeRequest")
CALL WORKER('MyProcess"; "DoSomethingElse")

And in the MakeRequest method:

// Do stuff
$request:=4D.HTTPRequest.new($someAPI; $requestOptions)
$result:=$request.wait()
// Do more stuff

The worker will execute “MakeRequest” first, up to when $request.wait() is called. Then, while a response is awaited from the server, the worker starts executing “DoSomethingElse”. After “DoSomethingElse” finishes, the worker will go back to finish executing “MakeRequest”.