This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Should I check the app timer state before restop or restart it?

Is it acceptable if I stop an app timer for dozens of times when the app timer is actually stopped. Will the memory leak if I operates in these scenario.Does it affect whether use scheduler when I init the app timer?

Parents Reply
  • @Dave

    I have not confirmed it but I think it would be the safest way to maintain a state variable that registers if a certain app-timer is started or stopped.

    • Whenever you start a timer, you register in the state variable that it is started.
    • If you stop a timer, then you register in the state variable that it is stopped.
    • You only start an app-timer if the state variable indicates that the app-timer is stopped.
    • You only stop an app-timer if the state variable indicates that the app-timer is started.

    Try it to see if the behavior improves.

Children
No Data
Related