'DateTime listener, listen to the minute changes

I want to listen to the minute changes, for example, if it is 6:00, I want to listen when it is 6:01 and then 6:02, and so on.

There are two ways (not good enough) that I can think of doing this.

  1. I can setup a Timer.periodic which runs every second and check for the change in minute.

  2. I can setup a Timer.periodic which runs every second till the minute gets changed but after that it cancels itself and fires up another Timer.periodic which runs every minute.

Is there any better solution than these workarounds?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source