Hi , I have a long loop to read and write a matrix, this works fine
with android with DoEvents in the code to do events
like handeling button clicks.
With IOS the main thread is blocked , I read on this form that
you can split the loop into some parts so the main thread
will not be blocked,you can do this with Callsubdelayed.
Each Callsubdelayed will be executed when the previous is
finished.
So I tried this but it does 'nt work.
Here is my source:
Output is :
loop1
loop2
loop3
loop4
This is ok , but when button2 is pressed the reaction is after all the loops
are finished , So the complete loop stil blocks all the button events.
Buttons have a very low priority in (IOS or B4i ?) can I change this ?,so it will
not be blocked by a simple Loop.
Maybe I use Callsubdelayed wrong, has anyone tried this before ?
with android with DoEvents in the code to do events
like handeling button clicks.
With IOS the main thread is blocked , I read on this form that
you can split the loop into some parts so the main thread
will not be blocked,you can do this with Callsubdelayed.
Each Callsubdelayed will be executed when the previous is
finished.
So I tried this but it does 'nt work.
Here is my source:
B4X:
Sub Button1_Click
loop1
End Sub
Sub Button2_Click
Button2.Text = "Pressed!"
End Sub
Sub loop1
Button2.text = "loop1"
Dim size As Int = 800000
Dim value As Int
For j= 0 To size
value = testarray1(j)
testarray2(j) =value
Next
If DateTime.Now > lastPreviewSaved + 100 Then 'shouldn't block main tread ?
lastPreviewSaved = DateTime.Now ' so change button2.txt ?
End If
CallSubDelayed(Me,"loop2")
End Sub
Sub loop2
Button2.text = "loop2"
Dim size As Int = 800000
Dim value As Int
For j= 0 To size
value = testarray1(j)
testarray2(j) =value
Next
If DateTime.Now > lastPreviewSaved + 100 Then
lastPreviewSaved = DateTime.Now
End If
CallSubDelayed(Me,"loop3")
End Sub
Sub loop3
Button2.text = "loop3"
Dim size As Int = 800000
Dim value As Int
For j= 0 To size
value = testarray1(j)
testarray2(j) =value
Next
If DateTime.Now > lastPreviewSaved + 100 Then
lastPreviewSaved = DateTime.Now
End If
CallSubDelayed(Me,"loop4")
End Sub
Sub loop4
Button2.text = "loop4"
Dim size As Int = 800000
Dim value As Int
For j= 0 To size
value = testarray1(j)
testarray2(j) =value
Next
If DateTime.Now > lastPreviewSaved + 100 Then
lastPreviewSaved = DateTime.Now
End If
End Sub
Output is :
loop1
loop2
loop3
loop4
This is ok , but when button2 is pressed the reaction is after all the loops
are finished , So the complete loop stil blocks all the button events.
Buttons have a very low priority in (IOS or B4i ?) can I change this ?,so it will
not be blocked by a simple Loop.
Maybe I use Callsubdelayed wrong, has anyone tried this before ?