[Gambas-user] timer overlaps

Christopher Brian Jack brian at ...1334...
Fri Jan 27 22:16:22 CET 2006


On Fri, 27 Jan 2006, Rob Kudla wrote:

> On Fri January 27 2006 13:26, Christopher Brian Jack wrote:
> > I was just on the subject of timer controls on another
> > response and a situation that may be of importance to me is
> > how well code can keep up with the timer.
>
> My solution is just to set a class-wide variable called something
> like CurrentlyInTimer to true at the start of the timer event
> handler, and back to false when the handler returns, and an if
> statement at the very beginning that just returns immediately if
> CurrentlyInTimer is set.

So you would be suggestion something like this?

Public Sub myTimer_Timer()
  ' increment master elapsed beat count
  INC $beatCount
  ' increment beats since last client call
  INC $scheduleCount
  ' call handler if not already in a call
  IF NOT $handlerActive THEN
    ' if enough client-reqested beats elapsed
    ' run his handler
    IF $scheduleCount >= $scheduleNext THEN
      ' flag on (avoid recursion)
      $handlerActive = 1
        ' dock the last client-requested count
        ' this total is running so we don't miss
        ' client calls (this assumes the client will
        ' normally keep up/catch up and that the client
        ' only periodically falls behind)
        $scheduleCount -= $scheduleNext
        'call client handler
        'he will return beats to wait
        'before calling him again
        $scheduleNext = Call($client, "Scheduler")
      ' handler done so flag off
      $handlerActive = 0
    END IF
  END IF
End Sub

.=================================================.
|  Christopher BRIAN Jack aka "Gau of the Veldt"  |
+================================================='
| brian _AT_ brians-anime _DOT_ com
| brian _AT_ animemayhem _DOT_ com
| brian _AT_ nall.brians-anime _DOT_ com
| brian _AT_ ruby.brians-anime _DOT_ com
| gau_veldt _AT_ hotmail _DOT_ com
`=================================================-
Hi Spambots, my email address is sputnik at ...1334...





More information about the User mailing list