D davemorris Active Member Licensed User Longtime User May 9, 2020 #1 Hi, Guys Can someone clarify if it is OK to re-initializer a timer several times within the same activity i.e. B4X: Expand Collapse Copy TimerName.initialize(....) Sorry about the basic question, but I am sure I read somewhere on forum or in the documentation (an now can't find it) that timers should only be initialized once. Regards Dave
Hi, Guys Can someone clarify if it is OK to re-initializer a timer several times within the same activity i.e. B4X: Expand Collapse Copy TimerName.initialize(....) Sorry about the basic question, but I am sure I read somewhere on forum or in the documentation (an now can't find it) that timers should only be initialized once. Regards Dave
LucaMs Expert Licensed User Longtime User May 9, 2020 #2 davemorris said: Hi, Guys Can someone clarify if it is OK to re-initializer a timer several times within the same activity i.e. B4X: Expand Collapse Copy TimerName.initialize(....) Sorry about the basic question, but I am sure I read somewhere on forum or in the documentation (an now can't find it) that timers should only be initialized once. Regards Dave Click to expand... I don't think it could be a problem but... why do it? Just stop it (set Enabled to False) and maybe change the Interval property. Last edited: May 9, 2020 Upvote 0
davemorris said: Hi, Guys Can someone clarify if it is OK to re-initializer a timer several times within the same activity i.e. B4X: Expand Collapse Copy TimerName.initialize(....) Sorry about the basic question, but I am sure I read somewhere on forum or in the documentation (an now can't find it) that timers should only be initialized once. Regards Dave Click to expand... I don't think it could be a problem but... why do it? Just stop it (set Enabled to False) and maybe change the Interval property.
W wes58 Active Member Licensed User Longtime User May 9, 2020 #3 davemorris said: Hi, Guys Can someone clarify if it is OK to re-initializer a timer several times within the same activity i.e. B4X: Expand Collapse Copy TimerName.initialize(....) Sorry about the basic question, but I am sure I read somewhere on forum or in the documentation (an now can't find it) that timers should only be initialized once. Regards Dave Click to expand... The only reason I see of doing it, is if you are using it in different parts of your code and you are not sure whether the timer has been initialised before. So then you check whether it has been initialised and if not initialise it: B4X: Expand Collapse Copy If Not(TimerName.IsInitialized) Then TimerName.Initialize(....) End If Upvote 0
davemorris said: Hi, Guys Can someone clarify if it is OK to re-initializer a timer several times within the same activity i.e. B4X: Expand Collapse Copy TimerName.initialize(....) Sorry about the basic question, but I am sure I read somewhere on forum or in the documentation (an now can't find it) that timers should only be initialized once. Regards Dave Click to expand... The only reason I see of doing it, is if you are using it in different parts of your code and you are not sure whether the timer has been initialised before. So then you check whether it has been initialised and if not initialise it: B4X: Expand Collapse Copy If Not(TimerName.IsInitialized) Then TimerName.Initialize(....) End If
Erel B4X founder Staff member Licensed User Longtime User May 10, 2020 #4 Make sure to disable the timer before initializing it again or you will end with multiple ticking timers. Also recommended to make the timer a Process_Global variable. Upvote 0
Make sure to disable the timer before initializing it again or you will end with multiple ticking timers. Also recommended to make the timer a Process_Global variable.