Unresponsive while loop in FireMonkey for Android

  

I am writing a simulation where I move celestial bodies by continous calculation of orbits. The positions are updated 100 times before drawing the bodies at their new positions. I have tried two approaches and have problems with both of them.

Using a timer. Works in Windows and android, but a bit slow because the position calculation has to wait for the timer interval to end.

A while loop.
While simulating do
Calculate new positions
if 100 calc have been done then
begin Draw bodies at new positions, Application.ProcessMessages, end

This is much faster, and works on Windows, but on Android there is no response to the Stop button (setting simulating to false), so the app hangs and Android asks if I want to close it.

Any suggestions?

Comments are closed.