I did some modifications, when callSubUtils was not an internal library. I wanted to use this procedure, but I had to dig out in an older project with what I modified.
I did found a thread that was asking this.
What I actualy did, was that callSubPlus(2), would return a timer instead of a String, and added a Public Method for canceling that request. I was in the need right now, to cancel the ambient sensor readings (LIGHT) so not a flash lighting was giving me a false positive. Maybe it could be posible to include this modification for CallSubUtils in a future library update.
I did found a thread that was asking this.
What I actualy did, was that callSubPlus(2), would return a timer instead of a String, and added a Public Method for canceling that request. I was in the need right now, to cancel the ambient sensor readings (LIGHT) so not a flash lighting was giving me a false positive. Maybe it could be posible to include this modification for CallSubUtils in a future library update.
B4X:
'Similar to CallSubDelayed. This method allows you to set the delay (in milliseconds).
'Note that the sub name must include an underscore if compiled with obfuscation enabled.
Public Sub CallSubDelayedPlus(Module As Object, SubName As String, Delay As Int) As Timer
Return CallSubDelayedPlus2(Module, SubName, Delay, Null)
End Sub
'Similar to CallSubDelayed. This method allows you to set the delay (in milliseconds).
'Note that the sub name must include an underscore if compiled with obfuscation enabled.
'The target sub should have one parameter with a type of Object().
Public Sub CallSubDelayedPlus2(Module As Object, SubName As String, Delay As Int, Arg() As Object) As Timer
Return PlusImpl(Module, SubName, Delay, Arg, True)
End Sub
'Similar to CallSub. This method allows you to set the delay (in milliseconds).
'Note that the sub name must include an underscore if compiled with obfuscation enabled.
Public Sub CallSubPlus(Module As Object, SubName As String, Delay As Int) As Timer
Return CallSubPlus2(Module, SubName, Delay, Null)
End Sub
'Similar to CallSub. This method allows you to set the delay (in milliseconds).
'Note that the sub name must include an underscore if compiled with obfuscation enabled.
'The target sub should have one parameter with a type of Object().
Public Sub CallSubPlus2(Module As Object, SubName As String, Delay As Int, Arg() As Object) As Timer
Return PlusImpl(Module, SubName, Delay, Arg, False)
End Sub
Public Sub cancelDelay(tmr As Timer)
tmr.Enabled=False
RunDelayed.Remove(tmr)
End Sub
Private Sub PlusImpl(Module As Object, SubName As String, Delay As Int, Arg() As Object, delayed As Boolean) As Timer
If RunDelayed.IsInitialized = False Then RunDelayed.Initialize
Dim tmr As Timer
tmr.Initialize("tmr", Delay)
Dim rdd As RunDelayedData
rdd.Module = Module
rdd.SubName = SubName
rdd.Arg = Arg
rdd.delayed = delayed
RunDelayed.Put(tmr, rdd)
tmr.Enabled = True
Return tmr
End Sub