1# Timer Handler
2
3To handle the tasks of LVGL you need to call `lv_timer_handler()` periodically in one of the following:
4- *while(1)* of *main()* function
5- timer interrupt periodically (lower priority than `lv_tick_inc()`)
6- an OS task periodically
7
8The timing is not critical but it should be about 5 milliseconds to keep the system responsive.
9
10Example:
11```c
12while(1) {
13  lv_timer_handler();
14  my_delay_ms(5);
15}
16```
17
18If you want to use `lv_timer_handler()` in a super-loop, a helper function`lv_timer_handler_run_in_period()` is provided to simplify the porting:
19
20```c
21while(1) {
22    ...
23    lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */
24    ...
25}
26```
27
28 In an OS environment, you can use it together with the **delay** or **sleep** provided by OS to release CPU whenever possible:
29
30```c
31while (1) {
32    lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */
33    my_delay_ms(5);                    /* delay 5ms to avoid unnecessary polling */
34}
35```
36
37To learn more about timers visit the [Timer](/overview/timer) section.
38
39