Timers

davelew1s

Active Member
Licensed User
Longtime User
I'm writing an app which uses the serial ports, so far it almost works, using Timers..I have a few questions on Timers:-
1...Is it OK to use more than 1 timer at a time, it does work but is good/bad
2...If more than 1 is used when do they fire..are they connected in any way or does it depend on when they are Enabled?
3...Is it good or bad to jump to a Sub from within a timer, if you do does the timer still fire or is it suspended until it is exited..similar if you stay in a timer longer then the interval does it still fire?
Anyone got any thoughts on these?
Dave.
:sign0085:
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. There is no problem with using several timers.
2. They are not connected in any way.
Theoretically, each one will wait for its interval and then fire.
However timers can't fire when the processor is busy and not handling internal messages.
For example if you create an endless loop, timers will not fire at all.
That is unless you use the DoEvents keyword in the loop.
3. As written above, the timer will only fire after finishing the sub (and any other code in the Timer_Tick event).

You should set an interval that is large enough for the processor to finish all the code, otherwise it will just run slower.
 
Top