iOS Question CallSubDelayed

Moosi

Member
Licensed User
Longtime User
Hi,

I´m struggling with the concept of (fake)asynchronous tasks. What is the right way to deal with it?

That´s what I´m doing right now (Simplified for testing):
B4X:
Sub SetText(t As Int)
    Log("SetText: " & t)
    Label1.Text = "Count: " &t
End Sub

Sub Run
    For i=0 To 10
        Log("Run" & i)
        CallSubDelayed2(Me,"SetText", i )
    Next
End Sub

Sub BtnStart_Click
    For i=0 To 100
        Log("Click: " & i)
        CallSubDelayed(Me, "Run")
    Next
End Sub

I read several times from Erel to split up larger tasks to smaler ones and use CallSubDelayed to call them.
I´m as well doing this in the Main Task right now.

The result is right now:
I geht 100 times the Log("Click") and then the Log ("Run").
After all is finished, the Label jumps to "Count: 10" (obviously)

So, what I am doing wrong? In Android I would use DoEvents but that does not exist in iOS. What is the right way to deal with it?

i would be really happy if someone cold point me in the right direction.

Thanks for your help
Andreas
Attached the Test Project.
 

Attachments

  • iOS_CallSubDelayed.zip
    2.1 KB · Views: 271

Moosi

Member
Licensed User
Longtime User
Hi Erel,
thanks for your reply.
I want to update the Label accordingly to the progress of the For...Next

In reality I´m parsing a large XML with Sax, but the effect is the same. The Update is never fired until the job is done.
 
Upvote 0

Moosi

Member
Licensed User
Longtime User
yes I tested in release mode. Same Problem.

I have the same issue with httpUtils2. Downloading many images and I am not getting any progress until the end.

I seems to be all related to the same. While a loop is running, no updates to the GUI are happening.
 
Upvote 0

Moosi

Member
Licensed User
Longtime User
Sure, this is the file.
Ok, so there is no way of having some sort of progress while parsing and/or downloading?
Is the only option to just show a Spinning Icon for minutes?
 

Attachments

  • xmlAppfiles.xml
    84.6 KB · Views: 290
Upvote 0

Moosi

Member
Licensed User
Longtime User
Hmmm, thats exactly what I did.
CallSubDelayed2(Main, "MoveProgressBar", ProgressStep)

Where MoveProgressBar moves the Bar :)
 
Upvote 0

Moosi

Member
Licensed User
Longtime User
Thanks Erel,
I think even on an Iphone4 it will be ok, just the parsing.
I wanted to move the progress with every step in the process chain.
Starting with DoSomeSQL, ServerConnet, DownloadXML, ParseXML, DownloadFiles...

I think that the UserExperience is better if something happens, rather than seeing a blank screen.
 
Upvote 0

Moosi

Member
Licensed User
Longtime User
Many Thanks,
asynchronous SQL would be wonderful...
right now I am testing if it is better to call the Label/Progress directly from the JobDone or use a CallSubDelayed.

The next step will be to test if there are problems with downloading 500+ Files via httpUtils2.
Are there known issues? With B4A ist´s working verry good....
 
Upvote 0

Moosi

Member
Licensed User
Longtime User
Asynchronous SQL commands are now supported.
perfect, thanks for your effort.

It´s working pretty fast with 500 Files.
As the Files are dynamicaly generated it would be more load on serverside to generate all and zip them.
I think I´m pretty happy with the solution for now.
 
Upvote 0
Top