Questions tagged [timer]
This tag is for questions about using timers in code to make things happen in a certain order or for gathering amount of time elapsed.
314
questions
4
votes
1
answer
466
views
Threadsafe Non-Overlapping Timer
I was working on a project recently, where I needed to process some tasks periodically, but the execution of those tasks could not overlap with one another. ...
1
vote
0
answers
96
views
Thread-safe key-value cache with expiration
I need my cache hold items to be accessible by key. The items should disappear after a configured time period. I do not need the lifetime of items to be exactly as configured. All I need is to make ...
8
votes
1
answer
128
views
Simple reminders timer in C99 for POSIX
This is my first time trying out C. Simplicity was the main objective. Signals are not handled and memory is not freed (program is very small, and the OS should take care of that when program exits).
...
3
votes
1
answer
74
views
scoped timer class (3rd revision)
Again, here is the previous question. I have (re)revised my custom scoped timer using the valuable feedback I got from a helpful member of this community. However I feel the need to ask this question ...
3
votes
1
answer
1k
views
Script to stop a program after a certain amount of time
I created this script because the Spotify desktop app doesn't have a built in sleep timer, and I needed one. I made it as easy to use as possible, and it can close other programs because it asks for ...
5
votes
2
answers
130
views
Basic scoped timer struct (extensively redesigned)
Here is the original question. I have extensively revised and redesigned my custom scoped timer for my needs using the feedback I got from two helpful members of this community. However I was told to ...
1
vote
0
answers
374
views
Detect Idle Time in React and JavaScript
I'm creating a functionality that detects idle time for an app if there's no activity within an hour. It works ok but I'm not sure if the approach to handling inactivity is correct? and how do I make ...
5
votes
1
answer
230
views
Function to format time, from seconds to a particular expresion
From an integer X representing a time duration in seconds produce a simplified string representation.
For example, given X=100, you should output: "1m40s"
Use the following abbreviations w,d,...
0
votes
1
answer
78
views
Creating custom setTimout function using requestAnimationFrame loop
I created a function using requestAnimationFrame loop that works pretty much like the plain JS setTimeout function (except that ...
5
votes
3
answers
2k
views
Heartbeats per minute in vanilla HTML JS
Attached is a fun little snippet demonstrating a button to be clicked along with your heartbeat and see how many beats per minute you're at. This is a mwe of the concept, any feedback is appreciated.
...
5
votes
1
answer
566
views
Bash script simple countdown timer with dotted output
My goal is to have a timer function that operates from the bash linux command line. I am looking for review and feedback. Printing the expected number of characters (dots, dashes, or bars) is nice-...
4
votes
1
answer
2k
views
Timer thread implementation
I've implemented a timer thread whose job is to call functions at a certain interval. The functions may be called multiple times if their interval > 0 millisec otherwise only one time. Even if the ...
4
votes
2
answers
123
views
I wrote a simple time measurement/compare library in C++ [TimeIt]
C++ Timeit
A quick C++ library to measure/compare code execution time
Features
Easy include and just call timeit() or ...
2
votes
1
answer
137
views
Clear output line in terminal after use for countdown (different length strings)
The method to overwrite the same line is well known and I use it for countdown, but what about when the next output string has a different size and will be generated by a single print? That's the ...
5
votes
3
answers
409
views
Templatizing a Timer class
I'm making a timer class in C++. This is the overview:
...
1
vote
0
answers
139
views
Timer with input, sound and flashing ( Just timer :) )
I know that this program is not very outstanding, but I'm learning "Python" and decided to publish this code in order to get some advice and parting words and overall evaluation of the ...
2
votes
1
answer
152
views
Program to check if a window is opened or not during some time interval
I'm trying to write a program that will check if a window is opened or not, during a given time. I was able to do that, but now I'm trying to make my code look cleaner. I don't like how I implement ...
6
votes
3
answers
955
views
Python analog clock with turtle - runs slow
I made a python analog clock program with turtle. The problem is, it takes about 1.4 seconds to loop, so it only moves the second hand every 1.4 seconds. Its probably cuz my computer is slow...
...
8
votes
0
answers
567
views
A VBA program to quantify the performance of code execution timers
Motivation
I am interested in optimising the execution time of code with short (fast) execution times on the order of microseconds (µs), but that will be used with high frequency (e.g. like ...
2
votes
1
answer
254
views
Leaky Bucket Algorithm with no Queue
Basic implementation of a leaky bucket, the idea is you call it by saying I will allow e.g. 5 login attempts per 60 seconds.
...
6
votes
3
answers
1k
views
Safe Windows API Timers for Excel
Update Feb 2023
This solution is no longer maintained here or on GitHub, mainly because I do not need a timer solution anymore. As seen below, the only purpose of this approach was to get a reliable, ...
3
votes
2
answers
1k
views
Retry a callback function n times until success
I want to make a function to retry calling callback n times until it return TRUE;
Here's my current code:
...
4
votes
9
answers
400
views
Simple stop watch class
I've made a little library where I add some functionalities from time to time that I miss in the Java standard library.
I am sad that the Java library for example has no stop watch class that allows ...
3
votes
1
answer
451
views
Simple stopwatch in C
A very simple stopwatch. Intended to be used for simple benchmarking when you want to do a task several times, but exclude some setup code from the benchmarking.
Some things I have already considered:
...
3
votes
1
answer
1k
views
Timer for event throttling
I have the following problem. I want to write a class that handles events and passes it through but reduce its number if there recently was an event. Basically it is debounce. However there is a ...
7
votes
2
answers
4k
views
Time duration conversion with units
I recently was asked to upgrade some C++11 code to add a feature by which the user can set a time duration from the command line of the program. The requirement was to have a default time of 1500 ms ...
6
votes
3
answers
836
views
A priority based timer using priority queue
I am trying to implement a priority-based timer where certain events are fired out based on their expiry and the priority.
So if there are 3 timers with the following expiry time and priorities
...
2
votes
1
answer
754
views
watchdog for c++11
I created a watchdog/notifier in C++ and wanted to make it better so it could be used by multiple people. The idea is that there is a timer class and event. client create events and pass a lambda ...
7
votes
1
answer
799
views
Digital clock with Python Tkinter
While learning about python tkinter, I decided to make a digital clock:
...
3
votes
0
answers
229
views
C# class library for managing recurring background operations
I have written a class library for creating timer-based bacground operations in .NET projects. The idea is to be able to create and manage (start/stop/resume/cancel) recurring background operations ...
3
votes
0
answers
53
views
Python script that getting list of all files with specific ext starting from the current folder. Using timer for reporting about the process
I am using a function that returns a list of all files (full path for each of them) with the given extension in the given folder and all subfolders.
As the process is quite long and user can get ...
2
votes
3
answers
6k
views
A Countdown Timer with reset functionality in pure Javascript
This works for me, but is this the right way to create this timer?
I might be naive about this but I think this is close to perfect in pure JS.
What would be the drawbacks of using this Timer compared ...
3
votes
1
answer
437
views
Windows high resolution timing class
I'm attempting to implement a high resolution class used to time the execution time of functions in Windows. After using this documentation, I have come up with the following:
...
2
votes
1
answer
53
views
Detect discontinuities in Windows clock in Java
Please review the code below, which detects discontinuities in Windows system clock in long-running programs.
...
3
votes
2
answers
510
views
Timer with interval function
I've been tasked with writing a function that executes a passed function every interval, passed to the function by the user. Below is the code, and how to call it:
...
1
vote
1
answer
93
views
Allow adding errors and warnings and remove both after a while with seperate timers
I use this in my Blazor application, letting other services send errors or warnings to this AlertService. The service triggers an update of a component which simply displays the messages, errors in ...
4
votes
0
answers
144
views
Just a digital clock in Swing
I've written a little clock implementation in Java Swing. It now seems to work flawlessly after having terrible Swing specific timing problems. Please indicate if this is the way to draw the clock and ...
3
votes
0
answers
53
views
n executions of a periodic goroutine
I'm new to Go and have a use-case for periodically executing an async work-function. I want the interval between work-function executions to be constant (not the time between one finishing and the ...
7
votes
1
answer
190
views
JS stopwatch using the observer pattern
I'm learning OOP and also trying to learn and implement some design patterns.
This question is a follow-up of Stopwatch interface OOP (Vanilla JS)
The app is available in https://nacho-p5.github.io/
...
8
votes
3
answers
370
views
Stopwatch interface OOP (Vanilla JS)
I'm learning OOP and the first exercise of the course was to made a Stopwatch class. I did it really fast and decided to make an interface for this little app.
I created the interface. Basically I ...
2
votes
0
answers
45
views
Refresh the List box with new rooms from the server every 3 seconds [closed]
So i have a server which I send a Request to and it sends me back a list of rooms,Now i made a window for joining rooms and I'm trying to refresh it every 3 seconds but when i use the Timer thread to ...
1
vote
2
answers
631
views
sleepless timer that does not lose time and handles spurious wakes
I have written a timer class.
Here it is in all its "glory" with some functions around it to test it:
https://rextester.com/LQSXUA43758
Below is the class on its own, note it also relies on ...
0
votes
1
answer
798
views
Run a timer while waiting for user input [closed]
I am making a C# console maths test where the user answers maths questions.
I am trying to add a timer to the test, I have managed to make a timer but when I run my code it becomes a mess!
Here is ...
2
votes
2
answers
65
views
Simple Timer Program
I have built a timer program in JavaScript. It decrements one counter every second, and if that counter is at zero, it decrements another counter, and sets the first counter to 59. If the second ...
2
votes
1
answer
1k
views
Timer in Java with GUI
I have created a timer with GUI in Java.
Here's the code:
...
3
votes
1
answer
2k
views
Timer for scheduling tasks in C++11
I have made a simple Timer class used for scheduling tasks. While defining the interface, I have followed the interface of a ...
3
votes
1
answer
421
views
ValueAnimator for IOS - Did I butcher it up?
I am trying to make an IOS tool similar to Android's ValueAnimator... more or less
This is useful for situations where you simply want a value to "animate" over time, but rather than necessarily ...
5
votes
2
answers
340
views
Productivity/Timer app that uses twilio to send SMS-reminders
I wrote a timer app in python using both twilio and the timer module; sends an sms to my phone after a certain amount of time has passed. While it works without a doubt, I wanted to gather some ideas/...
3
votes
1
answer
97
views
Plot timings for a range of inputs MkII
To celebrate questions getting more reputation points per upvote, I revisited my previous question, Plot timings for a range of inputs.
Since the time of that original question (more than two years!),...
14
votes
1
answer
1k
views
Tick. Tick. *breathe* BOOM! - Setting up real, stable asynchronous callbacks with WinAPI Timers in VBA
WinAPI Timers can be quite tricky to work with, as anyone who's tried to use them and fallen foul of one of the many pitfalls probably knows. Problems such as screen freezing, crashes, uncontrolled ...