Jump to content
Fabian1648

[Android] [FMX] Task synchronization problem with Android

Recommended Posts

Hello,


I want to display a "loading in progress" screen while a REST request is retrieving data from a server (execution time: 1.5 seconds with Windows, 6 seconds with Android): On click of a button on the initial form, the app display the "loading in progress" screen and start the REST request. At the end of the REST request, return to the initial form.

 

1) With windows, if I use the following code:
 

Quote

 TabControl1.ActiveTab:={tab corresponding to "loading in progress screen"};
 {Start REST Request};

 

The "loading in progress screen" is displayed after the end of the REST request.

 

 

2) With windows, if I use the following code:
 

Quote

  TabControl1.ActiveTab:={tab corresponding to "loading in progress screen"};

  tthread.CreateAnonymousThread(
    procedure
    begin
     {Start REST Request}
    end).start;

The "loading in progress screen" is displayed and the REST request start.

 

 

But on Android, it doesn't work: The REST request runs but the screen "loading in progress screen" is never displayed.

 

How can I proceed to have the right behavior?


Thank for your help

Share this post


Link to post

The 2nd approach is correct - do the REST request in a background thread, leaving the UI thread free to manage the UI. You can update the UI to hide the progress screen when the thread is finished.

 

We can't tell you why the progress screen is not displaying correctly, as you did not show a complete example. Maybe you are still blocking the UI thread in a way that we can't see. Are you able to display the screen if you disable the REST request?

 

Please show a more complete example from start to finish.

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×