I am french so sorry for my english i do my best...
I try to call a sub named timer1_tick and i want it to stop my sub "b_reponse1_click". The problem is that my sub dont wait until the end of the timer...
Code:
Sub Process_Globals
Dim Timer1 As Timer
....
End Sub
Sub Activity_Create(FirstTime As Boolean)
Timer1.Initialize("Timer1", 1000) ' 1000 = 1 second
Timer1.Enabled = True
...
End Sub
Sub b_reponse1_Click
p= p + 1
If b_reponse1.Text = r5 Then
score = score + 1
b_reponse1.Color=Colors.Green
CallSub("",timer1_tick) ' Here i call sub timer1_tick
b_reponse1.Color=Colors.Gray
Else
b_reponse1.Color=Colors.Red
b_reponse1.Color=Colors.Gray
End If
If nbqpassee = 10 Then
Activity.RemoveAllViews
Activity.LoadLayout("lay_main")
Else
CallSub("",loadq)
End If
End Sub
Timer1 countdown but my sub b_reponse1_Click continue execution without waiting the end of timer
Timer :
Code:
Sub timer1_tick
t = t + 1
Log(t)
End Sub
I have try this but didn't solve my problem :
Code:
Sub timer1_tick
t = t + 1
Log(t)
timer1.Enabled = False
End Sub
Do you know how can i do to stop my sub b_reponse1_click about to 1 second ?
Thanks by advance for answer !
timer1_tick is a regular sub like any other sub. It will not cause the code execution to wait.
Search the forum for CallSubPlus. You can break your current sub to two subs and then call the second sub with CallSubPlus which will run after the specified time.