Timers doesn't work!

lorebf

Member
Licensed User
Longtime User
The timers i have doesn't work... The program never enters the sub..

Here's my code:

B4X:
Sub Process_Globals
   Dim timer1,timer2 As Timer
End Sub

Sub Globals
   Dim can1 As Canvas
   Dim x,y,mx,my As Int
   Dim rektangel As Rect
   Dim done As Boolean
End Sub

Sub Activity_Create(FirstTime As Boolean)
   can1.Initialize(activity)
   can1.DrawColor(Colors.White)
   rektangel.Initialize(0,0,1,1)
   timer2.Initialize("timer2",40)
   timer2.Enabled=True
   timer1.Initialize("timer1",1)
   timer1.Enabled=True
'   Testritning
   done=False
   Do While done=False
   DoEvents
   Loop
End Sub
Sub timer2_tick()
   activity.Invalidate
   DoEvents
End Sub
Sub timer1_tick()
   drect(Rnd(0,400),Rnd(0,400),Rnd(1,20),Rnd(1,20),Colors.Black)
End Sub
Sub drect(x1,y1,xsize,ysize,clor As Int)
   rektangel.Top=y1
   rektangel.Left=x1
   rektangel.Right=x1+xsize
   rektangel.Bottom=y1+ysize
   can1.DrawRect(rektangel,clor,True,1)
End Sub

Edit:
Found out whats wrong... i deleted the loop, and it started working...
 
Last edited:
Top