Why when I use B4XLoadingIndicator it gets stuck when I query SQLite, or even I run a For i = 1 To 10000
ProgressDialogShow("Progress") does not crash.
Is there any way to improve the B4XLoadingIndicator code so that it doesn't crash?
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private lb_processando As B4XView
Private li_processando As B4XLoadingIndicator
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
li_processando.Show
End Sub
Private Sub lb_adicionar_Click
ProgressDialogShow2("Progress", False)
Sleep(100)
For i = 1 To 10000
lb_processando.Text = $"Progress ${i}"$
Next
ProgressDialogHide
End Sub
the application does not give an error.
but it looks like it gets all processing for the For i = 1 To 10000 and it doesn't process the B4XLoadingIndicator , but the ProgressDialogShow continues processing.
No. You need to improve your code and never hold the main thread too long. This is very easy to do. Simply use asynchronous queries: [B4X] SQL with Wait For
And that was my last post in this thread.
So why are you keep writing "crashes"? It doesn't crash.
Crash = app quits unexpectedly.
No. You need to improve your code and never hold the main thread too long. This is very easy to do. Simply use asynchronous queries: [B4X] SQL with Wait For
And that was my last post in this thread.
please help me implement for B4XLoadingIndicator not to pause processing when For i = 1 To 10000 is happening
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private lb_processando As B4XView
Private li_processando As B4XLoadingIndicator
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
li_processando.Show
End Sub
Private Sub lb_adicionar_Click
ProgressDialogShow2("Progress", False)
Sleep(100)
For i = 1 To 10000
lb_processando.Text = $"Progress ${i}"$
Next
ProgressDialogHide
End Sub
Just put sleep to for loop, B4XLoadingIndicator will not to pause processing
B4X:
Private Sub lb_adicionar_Click
ProgressDialogShow2("Progress", False)
For i = 1 To 10000
sleep(0) '<---------Added
lb_processando.Text = $"Progress ${i}"$
Next
ProgressDialogHide
End Sub
Just put sleep to for loop, B4XLoadingIndicator will not to pause processing
B4X:
Private Sub lb_adicionar_Click
ProgressDialogShow2("Progress", False)
For i = 1 To 10000
sleep(0) '<---------Added
lb_processando.Text = $"Progress ${i}"$
Next
ProgressDialogHide
End Sub
yes, that makes android wait a bit, and process everything it has to process before going to the next next...
it just happens that it takes a lot longer to execute the for...
is there something to say for android, look, do this process here regardless of what you are doing...
note that the progress doesn't stop even if I don't put a sleep
Private Sub lb_adicionar_Click
ProgressDialogShow2("Progress", False)
For i = 1 To 10000
If i Mod 100 = 0 Then
Sleep(0) '<---------Added
lb_processando.Text = $"Progress ${Round(100 * i / 10000)}%"$
End If
Next
ProgressDialogHide
End Sub