New topic: 

Timer not (always) firing

<http://forums.realsoftware.com/viewtopic.php?t=47087>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        JimPitchford          Post subject: Timer not (always) 
firingPosted: Tue Feb 26, 2013 12:57 pm                         
Joined: Mon Apr 11, 2011 2:01 pm
Posts: 139                I know that Timers are generally considered by users 
of RealBasic to be very reliable, but I am having some difficulties with some 
timers that seem to be not firing properly on about 20% of occasions.

I am using the Timers to effect movement of some containerControls and Canvases 
to their target positions. I send the object their target positions, and the 
timer is then used to calculate a number of interim steps (say 3 or 4) and set 
the left, top, width, height properties to those interim positions and issue an 
invalidate (or mark as dirty).

The code is of the form:

On creation of the new containerControl or cloning a Canvas (timer period = 50):
stepTimer = new Timer
AddHandler stepTimer.action, addressOf Move_OneStep
stepTimer.Period = gTab_TimerPeriod


On sending the target position to the control:
if stepTimer.mode <> timer.modeOff then
  stepTimer.mode = timer.modeOff //turn off if not already finished
  height = target_h
  wMain.LB1.addRow "TabBar Reset" //monitor what's going on
else
  wMain.LB1.addRow "TabBar"//monitor what's going on
end if

stepTimer.mode = timer.ModeMultiple //set the timer going


And the code triggered by the timer:
Private Sub Move_OneStep(sender as timer)
  move_Step = move_step -1
  
  dim c as string = wMain.LB1.cell(wMain.LB1.LastIndex, 1) //monitor what's 
going on
  wMain.LB1.cell(wMain.LB1.LastIndex,1) = c + " " + str(move_step) //monitor 
what's going on
  
  self.height = target_h - (target_h - orig_h) * move_step/gTab_MoveSteps  
//change the objects position
  
  if move_step <= 0 then
  stepTimer.mode = timer.ModeOff //turn off after the last step
  end if
  
End Sub


What I find is that the second routine runs correctly (stating "TabBar") in the 
list box, but every so often the timer does not fire, and I don't get the 
associated move_step shown (it should cycle through to 3,2,1,0). On the next 
run through the timer mode is not ModeOff and it resets stating "TabBar Reset".

Can anyone see what I'm doing wrong?

Jim      
_________________
Jim
OSX 10.8.2, rb2012r2  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to