Android Question Timer

hookshy

Well-Known Member
Licensed User
Longtime User
I am using a timer to show every 300 ms a diferent bitmap image inside of a imageview depending on some values that read from a file .
What happens if the time to process the code inside timer_click sub requires more than 300 ms ?(searching big array of data, in my case I use exccesive substring2 function).
I noticed that my battery got low very fast though i was downloaded the source text every 15 seconds with http.util .

When using timers do you have to wory about the time the timer ticks in order to let the processor handle the code inside?
 

lagore

Active Member
Licensed User
Longtime User
If you are worried that your processing will overrun the length of the timer tick then disable the timer in the timer tick event, do all of your processing then re enable then timer, otherwise you might get into some nasty loops.
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
thank you Iagore.

It is correct if how I tried to calculate time to execute the code inside timer
B4X:
sub timer_tick
tick_i=datetime.now
'my code
tick_f=datetime.now

log(tick_i-tick_f)
end sub
 
Upvote 0
Top