LucaMs Expert Licensed User Longtime User Jun 13, 2016 #1 a) Property Timer1.IsEnabled b) Timer1.Pause and Timer1.Continue - to suspend-resume the "timer activity". Please, see also this thread: https://www.b4x.com/android/forum/threads/protected-routine-or-timer1-isenabled.67870/ Last edited: Jun 13, 2016
a) Property Timer1.IsEnabled b) Timer1.Pause and Timer1.Continue - to suspend-resume the "timer activity". Please, see also this thread: https://www.b4x.com/android/forum/threads/protected-routine-or-timer1-isenabled.67870/
Erel B4X founder Staff member Licensed User Longtime User Jun 13, 2016 #2 a) How is it different than Timer1.Enabled? b) You can disable the timer to pause it and then enable it to resume it. Note that timer events will never fire while your code is executing.
a) How is it different than Timer1.Enabled? b) You can disable the timer to pause it and then enable it to resume it. Note that timer events will never fire while your code is executing.
LucaMs Expert Licensed User Longtime User Jun 13, 2016 #3 Erel said: a) How is it different than Timer1.Enabled? Click to expand... Timer1.Enabled "starts" or "stops" the timer's "activity" (can I say "its countdown"?). Timer1.IsEnabled should be used to check if it was enabled (started). Erel said: b) You can disable the timer to pause it and then enable it to resume it. Click to expand... I can (will) try but if you disable and then re-enable the timer, it will start from 0 (please, let me write in Italian ). I mean: if I wanted to suspend the timer? I set Timer1.Interval to 1 minute; then I need to do something when the minute is not passed (or simply the user presses Home). I have to create a process global variable which stores the time passed and on activity resume I have to set the new Timer1's interval to the difference, the remaining time. Also, I have to reset again the Interval to 1 minute. With Timer1.Pause - Timer1.Resume: Code: Copy Sub Activity_Pause(...) If not(UserClosed) then Timer1.Pause ... Sub Activity_Resume ' Here I could have the need of: If Timer1.IsEnabled Then Timer1.Resume ...
Erel said: a) How is it different than Timer1.Enabled? Click to expand... Timer1.Enabled "starts" or "stops" the timer's "activity" (can I say "its countdown"?). Timer1.IsEnabled should be used to check if it was enabled (started). Erel said: b) You can disable the timer to pause it and then enable it to resume it. Click to expand... I can (will) try but if you disable and then re-enable the timer, it will start from 0 (please, let me write in Italian ). I mean: if I wanted to suspend the timer? I set Timer1.Interval to 1 minute; then I need to do something when the minute is not passed (or simply the user presses Home). I have to create a process global variable which stores the time passed and on activity resume I have to set the new Timer1's interval to the difference, the remaining time. Also, I have to reset again the Interval to 1 minute. With Timer1.Pause - Timer1.Resume: Code: Copy Sub Activity_Pause(...) If not(UserClosed) then Timer1.Pause ... Sub Activity_Resume ' Here I could have the need of: If Timer1.IsEnabled Then Timer1.Resume ...
LucaMs Expert Licensed User Longtime User Jun 13, 2016 #4 Erel said: Note that timer events will never fire while your code is executing. Click to expand... I have to understand / try this
Erel said: Note that timer events will never fire while your code is executing. Click to expand... I have to understand / try this
Erel B4X founder Staff member Licensed User Longtime User Jun 13, 2016 #5 Timer.Enabled is a get / set property. You can get its value: Code: Copy Dim IsEnabled As Boolean = Timer1.Enabled LucaMs said: I set Timer1.Interval to 1 minute; then I need to do something when the minute is not passed (or simply the user presses Home) Click to expand... You should use a service in that case. The timers will not be affected by the application life cycle.
Timer.Enabled is a get / set property. You can get its value: Code: Copy Dim IsEnabled As Boolean = Timer1.Enabled LucaMs said: I set Timer1.Interval to 1 minute; then I need to do something when the minute is not passed (or simply the user presses Home) Click to expand... You should use a service in that case. The timers will not be affected by the application life cycle.
LucaMs Expert Licensed User Longtime User Jun 13, 2016 #6 Erel said: Timer.Enabled is a get / set property. You can get its value: Code: Copy Dim IsEnabled As Boolean = Timer1.Enabled You should use a service in that case. The timers will not be affected by the application life cycle. Click to expand... Timer.Enabled seem to be both, a property but also a method; you use it to start the "timer's countdown". Anyway, your hint (to check if it is "active") is right (of course ) . About services... I have to study if I can help "him" using them. Sure not today, today my brain needs: "LucaMs.Pause" What about that "stopwatch" object? Is it not useful? Thank you, Erel Last edited: Jun 13, 2016
Erel said: Timer.Enabled is a get / set property. You can get its value: Code: Copy Dim IsEnabled As Boolean = Timer1.Enabled You should use a service in that case. The timers will not be affected by the application life cycle. Click to expand... Timer.Enabled seem to be both, a property but also a method; you use it to start the "timer's countdown". Anyway, your hint (to check if it is "active") is right (of course ) . About services... I have to study if I can help "him" using them. Sure not today, today my brain needs: "LucaMs.Pause" What about that "stopwatch" object? Is it not useful? Thank you, Erel
LucaMs Expert Licensed User Longtime User Jun 13, 2016 #7 Erel said: You should use a service in that case. The timers will not be affected by the application life cycle. Click to expand... Do you mean he (we) should use services with StartServiceAt instead of timers? But he uses many timers to show-hide-change images and to do other stuff and services have no GUI and are not related to Activities. I suppose he should pass GUI objects to them, but it is very complex, or not? Last edited: Jun 13, 2016
Erel said: You should use a service in that case. The timers will not be affected by the application life cycle. Click to expand... Do you mean he (we) should use services with StartServiceAt instead of timers? But he uses many timers to show-hide-change images and to do other stuff and services have no GUI and are not related to Activities. I suppose he should pass GUI objects to them, but it is very complex, or not?