B4J Question Stopping CallSubPlus

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

If you call a Sub using the CallSubPlus like below..

B4X:
csu.CallSubPlus(Me, "Sub_1", 9000)

Which runs the sub 'Sub_1' in 9 seconds, what if after 3 seconds you want it to stop and not run that sub?

Is there a way in stopping the CallSubPlus from running once it has been told to run ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can add this sub to CallSubUtils:
B4X:
Public Sub RemoveCallsToSub(SubName As String)
   If RunDelayed.IsInitialized = False Then Return
   Dim timersToRemove As List
   timersToRemove.Initialize
   For Each tmr As Timer In RunDelayed.Keys
     Dim rdd As RunDelayedData = RunDelayed.Get(tmr)
     If rdd.SubName = SubName Then timersToRemove.Add(tmr)
   Next
   For Each tmr As Timer In timersToRemove
     tmr.Enabled = False
     RunDelayed.Remove(tmr)
   Next
End Sub
1. Note that I haven't tested it.
2. It doesn't check the module, only the sub name.
 
Upvote 0
Top