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 !
WakeMainThread()
to "wake up" the main thread in a cross-platform manner because different platforms handle main thread event queues differently. At leastCheckSynchronize()
itself is cross-platform, but getting the RTL to call it is a PITA unless you call it yourself. – Lenee