I am using REST components in Delphi XE5 (iOS and Android). I am testing via the iOS simulator currently, and my application often hangs at the following line within my code:
R_Request.Execute;
After some debugging, I find it it specifically hangs at this line of code within the REST.Client.PAS:
HandleEvent(DoAfterExecute);
which looks like:
procedure TCustomRESTRequest.HandleEvent(AEventHandler: TMethod);
begin
// Handle Synchronized if we are NOT already in the main thread
// NEVER call synchronize on the MainThread - that might shift the island!
if SynchronizedEvents and (System.MainThreadID <> TThread.CurrentThread.ThreadID) then
TThread.Synchronize(TThread.CurrentThread, AEventHandler) // FAILS HERE
else
AEventHandler;
end;
It's either NOT returning the thread in the .Synchronize or taking an extremely long time ( 5 minutes or so ) ... It worked once while debugging, but has not ever since and again just now ( 30 min later, and after letting it set for 5 minutes to return a thread).
Help ? Or at least any sense of direction anyone can give me?
Again, developing for iOS and Android ( so FMX... ) and currently testing via iOS simulator. Thanks !
The problem is that TThread.Synchronize()
is broken in FireMonkey. See this QC report:
Report #123579: TThread.Synchronize() and TThread.Queue() do not work correctly in FireMonkey
This has only just recently been discovered, but it has been broken since FireMonkey was first introduced and nobody apparently noticed until now.
Until Embarcadero fixes it, try calling CheckSynchronize()
periodically in the main thread, such as in a timer.
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