[Gambas-user] timer overlaps
Christopher Brian Jack
brian at ...1334...
Sat Jan 28 01:46:43 CET 2006
I live in the complicated...
However that's the nice thing about classes...
Get it right once and you end up with a reusable solution to the problem.
.=================================================.
| 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...
On Fri, 27 Jan 2006, nando wrote:
> Date: Fri, 27 Jan 2006 17:42:58 -0500
> From: nando <nando_f at ...951...>
> Reply-To: gambas-user at lists.sourceforge.net
> To: gambas-user at lists.sourceforge.net
> Subject: Re: [Gambas-user] timer overlaps
>
> In some things I've done, I use the timer this way...
>
> Private GlobalTick AS INTEGER 'counts up one every Timer0 tick.
>
> Public Sub Timer0_Timer() 'This is the master timer set at 100 ms (10/sec)
> INC GlobalTick
> End Sub
>
>
> Public Sub Timer1_Timer()
>
> Timer1.Enable = False
>
> 'do your code here (graphics, computation, etc)
>
> Timer1.Value = 'use the GobalTick to determine how long you want
> to delay to the next Timer1 tick for repeat of graphics)
> GlobalTick = 0
> Timer1.Enable = True
> End Sub
>
> This way, If I desire 4 renders per second, that means that Timer1.Value
> has to be (250 - (4 - GlobalTick) * 100) without going below zero.
> This is the delay to the next Timer1 Event.
> The 250 above is 1000ms / 4 renders (for each second).
>
> You can easily set the processes per second you desire.
> You can easily find out the max your system can do because
> the delay will be zero (or negative)
>
> -Fernando
>
> ---------- Original Message -----------
> From: Christopher Brian Jack <brian at ...1334...>
> To: gambas-user at lists.sourceforge.net
> Sent: Fri, 27 Jan 2006 13:16:22 -0800 (PST)
> Subject: Re: [Gambas-user] timer overlaps
>
> > 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...
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files for problems? Stop! Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > http://sel.as-
> > us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> ------- End of Original Message -------
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list