how do you create a timer?
I meant: If thinking about a thread approach, do better use the API instead of a thread. (my english = my faultKale wrote:Honestly, threads are overkill for such an easy thing as a timer.inc. wrote:As youre going to create a thread you directly could use the API way pointed by Psychopanta and me.

-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
Just found this topic, warming it up a bit:
I find this approach quite useful for a small simulation utility that I'm currently developing. A GUI (primary thread) is used to manipulate a number of global variables. These variables are read by the thread and used to write NMEA-like sentences to an RS232 port with speeds varying between 20 and 60 sentences/sec.
EDIT: I just tested this non-api method on Xubuntu as well. It ran without a single modification. Hurray for a portable cross platform timer solution!
Thanks SRod & TheFool!
please note that if you model a real app on this, the last REPEAT/FOREVER loop (or any other form of loop for that matter) needs an extra Delay to reduce processor load, as in:srod wrote:You'll need to use the debugger to kill the following:
Code: Select all
Global timerquit Procedure Timer1(time) ;time is in milliseconds Repeat Delay(time) Debug 1 Until timerquit=1 EndProcedure ;fire the timer every second: CreateThread(@timer1(),1000) Repeat ForEver
Code: Select all
Global timerquit
Procedure Timer1(time) ;time is in milliseconds
Repeat
Delay(time)
Debug 1
Until timerquit=1
EndProcedure
;fire the timer every second:
CreateThread(@timer1(),1000)
Repeat
Delay(1)
ForEver
EDIT: I just tested this non-api method on Xubuntu as well. It ran without a single modification. Hurray for a portable cross platform timer solution!
Thanks SRod & TheFool!