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.

Filter by
Sorted by
Tagged with
3
votes
2answers
52 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
9answers
263 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
1answer
81 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
1answer
208 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 ...
6
votes
2answers
282 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
3answers
259 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
1answer
55 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
1answer
502 views

Digital clock with Python Tkinter

While learning about python tkinter, I decided to make a digital clock: ...
3
votes
0answers
93 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
0answers
47 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
3answers
2k 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
1answer
53 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
1answer
42 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
2answers
104 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
1answer
90 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
0answers
84 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
0answers
41 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
3answers
148 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
0answers
29 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
2answers
203 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 ...
1
vote
1answer
258 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 ...
3
votes
2answers
47 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
1answer
188 views

Timer in Java with GUI

I have created a timer with GUI in Java. Here's the code: ...
3
votes
1answer
778 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
1answer
283 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
2answers
330 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
1answer
80 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!),...
13
votes
1answer
716 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 ...
4
votes
0answers
91 views

React - pomodoro clock

I'm looking for some feedback on a pomodoro clock that I recently wrote with React. I'm pretty new to React and coding in general. I followed a couple of online courses, but I'm mostly self-taught. ...
2
votes
0answers
242 views

RxJs observables pipes SwitchMap and async with typealong search input

I'm using RxJs for type along search, I setup an observable to emit a value after 1 second so it behaves like http with delay. I subscribe to it via the async operator in the template, the component ...
1
vote
1answer
1k views

React continuous polling

I have a Notifications component in my React app, which continuously polls the server for new notifications. The app uses Redux for storing notifications. When a new notification is received, it is ...
1
vote
0answers
51 views

Limit framerate [closed]

I have made this class. Not sure if there is anyway to make it better. It seems to work alright half the time, but other times frames jump up higher then the set limit around 30frames more if i set it ...
3
votes
2answers
699 views

A simple stop watch which I want to extend

I am making a very simple stopwatch functionality as below. New will start the timer. Pause will suspend the watch. Start will restart again. Session will return the duration. ...
3
votes
2answers
270 views

A little C++ program to have timed rounds for a game

I know it could be better, but I’m new to C++, so I don’t know many of the tricks, along with some of the includes that are already obsolete. This program asks for names as input, adds a time for ...
4
votes
1answer
99 views

Single-thread Task Scheduler with type erasure and allocator-aware

I made a task scheduler to practice allocators and type erasure. With my project, you can delay execution of any callable (functions (using std::ref), lambdas...) ...
5
votes
2answers
67 views

Report time on whole hours

Report time at whole hours ...
7
votes
2answers
4k views

Safe Dispose of Timer

I am currently refactoring a larger solution where the compiler gave multiple warnings about disposing the used System.Timers.Timer instances. The timers are ...
5
votes
1answer
148 views

timer struct for fixed timestep iterations in C (gcc)

I was toying with a way force fixed timestep loop iterations in C and came up with a fairly simple timer struct (quite different from Pausable Timer Implementation for SDL in C and decided to put it ...
6
votes
2answers
248 views

pydoro - terminal tomato timer

I've recently created a tomato timer for terminal. It's hosted in github. My concerns are how Pythonic my code is? Is the way I'm handling state transitions good? Which areas of the text user ...
3
votes
1answer
74 views

Throttling promise execution (API requests, etc)

I was working on a client for a remote api and realized that I needed to throttle requests at a maximum rate of 4 Hertz (4 requests per second). I wrote a simple typescript class to do it and wanted ...
1
vote
1answer
160 views

Suppress API call in Redux Saga based on a timer

I have an API that provides data that is updated on an infrequent schedule, about once every 2½ minutes on average. Assuming that it's okay to fetch only as often as every 2½ minutes or less often, I'...
4
votes
0answers
76 views

Game clock with configurable rate

Edit: Licensed source can be found here. The intent behind this class is to allow different game systems to run at their own clock rate. The physics integration rate should not be connected to the ...
1
vote
0answers
508 views

Timer queue with chrono

I would like to make the timer queue: 1. Each timer has id, time expired and callback to call 2. Queue stores timer and execute the callback of each timer whenever expired. Here is my code and demo: ...
7
votes
1answer
159 views

Quiz game with timer

This is my first Go program. I would like to know what could be improved, what is done wrong, and anything else that I should know. The CSV contains 10 questions with the 10 answers separated by a ...
3
votes
1answer
2k views

Tkinter stopwatch

As part of a personal project, I wanted to make a stopwatch with Python. I wish to show my friend but at the moment it is a little messy and long. Is there any way to make it more compact or easier to ...
8
votes
2answers
225 views

Pausable Timer Implementation for SDL in C

Problem I've written a timer module in C for an SDL game. I'd like to get some eyeballs on. I wrote this for 2 requirements: I needed a timer that would signal on an elapsed interval, AND that was ...
3
votes
1answer
4k views

A countdown clock in TypeScript

The gist of the code is, you give it a date, it will start counting down how many days, hours, minutes and seconds left by emitting an event 'countDown' and once 0 is reached 'expired' event is ...
4
votes
1answer
371 views

C# Timed buffer

Purpose of this code is to have buffer which will batch messages based on configured timeout. For example, one thread will continuously push data to this buffer, and when configured timeout pass, it ...
5
votes
1answer
2k views

Algorithm to find the number of years, months, days, etc between two dates

I've been working on this one for a while. Took me a while to figure out all the logic rules for dates and months. The goal of this method is to return the number of years, months, days, hours, ...
1
vote
1answer
53 views

A simple Java class for implementing code stop watches - follow-up

I have received a nice answer for this post. Now, it is my attempt for some improvement: ...

1
2 3 4 5 6