[英]b4a Insert Timer in a code
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". 我尝试调用一个名为timer1_tick的子,希望它停止我的子“ 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 Timer1倒计时,但我的子b_reponse1_Click继续执行而无需等待计时器结束
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 ? 您知道如何停止我的sub b_reponse1_click大约1秒钟吗?
Thanks by advance for answer ! 预先感谢您的回答!
timer1_tick is a regular sub like any other sub. timer1_tick是与其他任何子程序一样的常规子程序。 It will not cause the code execution to wait.
它不会导致代码执行等待。
Search the forum for CallSubPlus. 在论坛中搜索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.
您可以将当前子项拆分为两个子项,然后使用CallSubPlus调用第二个子项,该子项将在指定时间后运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.