When i call a function and it "runs" (Can be take up to 3 seconds - refresh function getting data from api server) I would like to show a loadingform as an Ajax Loading Indicator as an overlay above the main form.
My previous attempts have all failed. I had tried to change the Create the LoadingForm that it is directly shown after the Main created. Then I tried LoadingForm.Show/Showmodal. In the modal sequence stops and only continues when I close the form and show the window does not close despite .
I also had the situation that the form was opened but the gif wasnt showing, the place where it should be was just white and stayed white - no image no animation
Any idear?

                        
The code below uses a thread to mimic a long time running block in its
Executemethod and theOnProgress"callback" to notify the form the percent done has changed.It's a very minimal example but it can show you one of the right directions in my opinion.
Notice that no error checking nor exception handling are currently performed.
Unit1.pasthe main form and the thread classUnit1.dfmUnit2.pasthe progress dialogUnit2.dfmReferring to the comment which states that the long time running operations need to access a grid in the main form, in order to avoid to block the VCL thread on that object:
ShowModalreturns.myRunProgressor in themyRunTerminatemethodFor different use cases a mixed approach could also make sense (pass the copy in the constructor/update the grid in a thread's syncronized block) if your routine doesn't take in account the already changed data: choose the method which best suits your needs.
If another external thread updates the grid, a
thread1could read the data then fill a form's private queue - say aTThreadListor another collection in aTCriticalSectionblock - and notify athread2to perform a job on the queue but I hope this is probably not needed to have your job done.