Android Question Flow of the program with CallSubDelayed

vecino

Well-Known Member
Licensed User
Longtime User
Hello, my question is: What problems can arise?

B4X:
Sub something1
  Show("aaa")
End Sub

Sub something2
  Show("bbb")
End Sub
 
Sub something3
  Show("ccc")
End Sub
   
Sub Show( cTxt As String )
  log(cTxt)
 
  CallSubDelayed(Me,"Show_Completed")
End Sub

Considering that it is not used Wait For Show_Completed
Thank you.
 

vecino

Well-Known Member
Licensed User
Longtime User
I have not found any problem
I "match" the "wait of" with their "callsubdelayed".
But I was looking at a partner's code and I saw that he does things similar to the code that I have set as an example.
So I was wondering what it can affect.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
after end sub of Show the sub
Show_Completed will just called if it exist in "Me"
i think without the delay this is more or less the same
B4X:
Sub Show( cTxt As String )
  log(cTxt)
 Show_Completed()
End Sub
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Then if "Show_Completed" does not exist, the following "Show" instruction will be executed, if it exists.
For example:
B4X:
Sub Show( cTxt As String )
  log(cTxt)
  CallSubDelayed(Me,"Show_Completed")
  log("Hello, World")
End Sub
"Hello world" will be displayed.

I thought that those instructions were left in a "queue" waiting to be executed. And the accumulation of those calls would fill the queue and cause some problem.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
yes, if you call the Show_Completed it will make a small delay (until this sub end) in your app direct.
and the collection of events call this Show_Completed unnecessary.

if you would store it as status you can act only at a new status.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
i hope you changed it in the right way :)
your example was very abstract / simplified.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Yes, it is a very simple example.
Although now I understand the concept better.
Thank you :)
 
Upvote 0
Top