I have a button that triggers a relatively long-running Sub, so I attempt to show a B4XLoadingIndicator when the button is clicked.
The indicator never shows up. I try putting a Sleep(0) or Sleep(50) after it, but that does not help. Do I need a longer Sleep() duration or a different approach?
Here's the button click Sub:
btn_Refresh Sub:
Private Sub btn_Refresh_Click
pbar_PleaseWait.Show
Log("Emptying B4XTable")
tbl_Codes.SetData(Array())
tbl_Codes.UpdateTableCounters
' tbl_Codes.ClearDataView
' TableSelections.Clear
Log("Building SQLite Database from legacy files")
Log("Cleaning 2022 data")
Clean2022FromDatabase
Log("Converting legacy text files")
ConvertLegacyCodesToSQliteDB
Log("Loading new SQLite database")
LoadCacheFromSqlite
Log("Populating B4XTable")
wait for (tbl_Codes.SetData(keysList)) complete (res As Object)
Log("Refreshing B4XTable")
tbl_Codes.RefreshNow
TableSelections.Refresh
Log("Done!")
pbar_PleaseWait.Hide
End Sub
I noticed if I have the indicator on when the app starts, that whenever that Sub is called (btn_Refresh), the indicator stops animating, even though the app continues to do what it does.
Once the app is done processing that Sub, the indicator starts up again. ?
How do I put the indicator on its own thread, maybe?