You can think of the timer subcomponent as a simple timer, with a simple task. You set the timer to a specified time or time interval. When time has passed, the timer method is called. Further, you can cancel the run of the timer method, get the state of the timer, and get the remaining time.
It is tempting to use the timer method for control logic and to create several timers in a project. But both ideas can have a big downside for your project. As a rule of thumb, use one or two timers in each logical section. Further, use the timer method only to all your state machine. If you do that, your code will be more efficient, simpler, easier to debug and maintain, and less error-prone.
Each time you add a timer you increase the complexity of your project, and you decrease the efficiency and predictability. In addition, each time you add control logic to a timer method, beyond calling your state machine, you increase the complexity further.
Try to use your timers in a general way, so you can use the same timer multiple times instead of creating a new. Try to use as few as you can. Think about if there is an alternative to a timer. Can you use e.g. the notification model or Get/Set methods?« Back to Glossary Index