RodM Member Licensed User Aug 20, 2021 #1 I made a simple timer to test the Sleep function, as in code below, and noticed that when I click the label, it logs as if I have clicked it twice. Could anyone tell me, please, why this happens? Code: Copy Private Sub Label3_Click IsRunning = Not(IsRunning) Do While True If Not(IsRunning) Then Log("Stop") Exit End If Label3.Text = DateTime.Time(DateTime.Now) Sleep(1000) Loop End Sub
I made a simple timer to test the Sleep function, as in code below, and noticed that when I click the label, it logs as if I have clicked it twice. Could anyone tell me, please, why this happens? Code: Copy Private Sub Label3_Click IsRunning = Not(IsRunning) Do While True If Not(IsRunning) Then Log("Stop") Exit End If Label3.Text = DateTime.Time(DateTime.Now) Sleep(1000) Loop End Sub
toby Well-Known Member Licensed User Longtime User Aug 21, 2021 #2 It works as expected. When the execution reaches Sleep(1000), it pauses for 1 second, handling control over to the system. One second later, the execution resumes from where it left off, running the Do While loop the second time. Upvote 0
It works as expected. When the execution reaches Sleep(1000), it pauses for 1 second, handling control over to the system. One second later, the execution resumes from where it left off, running the Do While loop the second time.
RodM Member Licensed User Aug 21, 2021 #3 Thank you, toby! I realized that, each time I click the label, it runs an instance of Sub Label_3_Click and, in that case, it can run two instances before stop. Thank you. Upvote 0
Thank you, toby! I realized that, each time I click the label, it runs an instance of Sub Label_3_Click and, in that case, it can run two instances before stop. Thank you.
Erel B4X founder Staff member Licensed User Longtime User Aug 22, 2021 #4 I think that you are looking for this: [B4X] Resumable subs and the index pattern Upvote 0
RodM Member Licensed User Aug 22, 2021 #5 Erel said: I think that you are looking for this: [B4X] Resumable subs and the index pattern Click to expand... Yes, that's what I was looking for. Thank you ! Upvote 0
Erel said: I think that you are looking for this: [B4X] Resumable subs and the index pattern Click to expand... Yes, that's what I was looking for. Thank you !