Page 1 of 1

Timer low CPU

Posted: Sun Mar 04, 2007 7:06 am
by Learner

Code: Select all

;--------------------
; Access PBOSL Timer from any code with Low CPU overhead
;  up to 1 ms - Learner
;--------------------
Global ObEvent.l

Procedure mytimer1()
  If Not pulseEvent_(ObEvent) ;Sets Event to Signaled then Reset to off
    Debug "darn "+ Str(ObEvent)
  EndIf
  
EndProcedure

ObEvent = CreateEvent_(#Null,#False,#False,#Null)

StartTimer(0, 10, @mytimer1());10 ms timer
Repeat
  MeasureHiResIntervalStart();meassure Speed 
  WaitForSingleObject_(ObEvent, #INFINITE);This reduces loop processor load
  Debug MeasureHiResIntervalStop();in seconds
  Delay(10) ;can leave this out
  If GetAsyncKeyState_(#VK_RBUTTON) ;end if right button pressed
    EndTimer(0)
    End
  EndIf
ForEver