A button on a window starts to retrieve lots of records from a database. I would like to display some text after button has been clicked and before retrieving records.
At the moment the text is not displayed after retrieve ends.
Hi Johann, see if this can help you.
You can insert in the window a Label without text (Label1.Text=“”) then in the pressed event of the button first show some text in the label (Label1.Text=“Please Wait …”) then start retrieving records.
At the end remove the text from the label (Label1.Text=“”).
On my pc it works.
When you do a long task the interface is blocked. Updating the interface in a long task is always a PITA. Check out the threads example in the Xojo folder. For instance, there is a folder “UpdatingUIFromThread” with 2 example files.
Add a Thread and a Timer to the Window and in the Run Event of this Thread, you put your Code to retrieve the Data.
Let this Thread load the Data into an Object you can reach outside of the Thread, like in a RowSet as a Property of the same Window. Set the Priority of the Thread to 2,3 or 4.
Then in your Button, you change the Label and afterwards, start the Thread. But always chek if the Thread is in a NotRunning State, before you try to start it.
The Thread can Start the Timer as soon as the Thread has finished the Job. The Timer can do whatever needs to be done with the Data the Thread retrieved.
I’d always vote for Threads (or Workers) when it comes to pull data from an external source or if the dataload is really heavy. Because connection issues, long calcs, etc. can make your app freeze.