Jump to content

Time remaining on "delay"


Recommended Posts

I apologize if this has already been asked. I've searched and haven't been able to find an answer to this. Is there a way to get the remaining time on a "delay"? For a timer workflow, I'd like to be able to check how much time is left instead of simply waiting for a notification once the delay has ended.

Link to comment
On 3/25/2020 at 7:37 PM, jdpinto said:

For a timer workflow, I'd like to be able to check how much time is left instead of simply waiting for a notification once the delay has ended.

 

You don’t want to use a delay for a timer. I don’t know how Alfred implements it, but since it’s meant for a few seconds at a time, it’s likely it tells the Workflow to wait the input seconds.

 

The trouble with that approach is that it’s not precise. As your OS decides which tasks get which cycles, the timer may not run in real time (e.g. if your machine becomes under heavy load and the timer process freezes, when it gets running again it will continue where it stopped). That’s not problematic if you’re waiting a few seconds, but it’s no good when you need a modicum of precision ove several minutes or hours.

 

The correct technique is to save the time at which the timer started and periodically compare it to the current time. That’s how time tracking apps keep counting even if the machine enters sleep mode. Incidentally, I’ve found out about all this when building SandwichTimer.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...