1.) The API function InstallEventLoopTimer_() seems to be defined incorrectly in PB.Niffo wrote:This code causes an "Invalid memory access", do you know why ?
Therefore I have imported this function and defined the 2nd and 3rd parameter as
type Double.
2.) The Callback has to be defined as ProcedureCDLL.
3.) You always should remove your timer afterwards with RemoveEventLoopTimer().
Code: Select all
ImportC ""
InstallEventLoopTimer(EventLoopRef.L, FireDelay.D, Interval.D, TimerProc.L, *UserData, *EventLoopTimerRef)
RemoveEventLoopTimer(EventLoopTimerRef.L)
EndImport
#kEventDurationSecond = 1.0
OpenWindow(0, 100,100, 300, 200, "Test Window")
ProcedureCDLL CallBackTimerHandler(theTimer, *userData)
Debug "Timer ="
EndProcedure
mainLoop = GetMainEventLoop_()
timerUPP = NewEventLoopTimerUPP_(@CallBackTimerHandler())
InstallEventLoopTimer(mainLoop, #kEventDurationSecond, #kEventDurationSecond, timerUPP, #Null, @theTimer)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
RemoveEventLoopTimer(theTimer)
