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
2
votes
2answers
102 views

Simple timer checking class

This is a simple class that runs a timer every 10 seconds to update the title with some information like how long the application has been up, depending on the datetime that is set in another class ...
1
vote
2answers
62 views

Reinitialize cache periodically, catching and logging any Throwables

My existing code has a scheduler that we init when a DataStore constructor is called. ...
3
votes
0answers
3k views

TTimerThread - Threaded timer class

I was inspired by @LU RD's answer to the question: Using VCL TTimer in Delphi console application, and wrote a bit simplified TTimerThread class. By simplified I ...
18
votes
3answers
484 views

“How are you spending your time on the computer?” Part 2

In my previous question I got some pretty good suggestions which really improved the overall performance of the controls, but I decided to extend the application and add some more features : You can ...
37
votes
4answers
7k views

“How are you spending your time on the computer?”

I've made a Windows Forms application to track all of the processes running on my machine and it also saves the time an application is "active", an active application is the one that is on focus ...
2
votes
2answers
3k views

Script to activate an alarm at a time in the future

I am making a flashlight plugin for macOS. Here is the main code, plugin.py, the method results gets called first and is passed ...
3
votes
1answer
187 views

Calling a function every 40 second inside a while loop

This code invokes a function for every 40 seconds inside a loop. I am doubtful about this condition: if ((time_left <= 0 || time_left > interval)) Is only ...
4
votes
1answer
187 views

Countdown AppIndicator

I've decided to translate an old Unity AppIndicator I had written in C to Ruby, so I can practice coding with it (got a little bored with the completely beginner lessons I've been following, which I'...
3
votes
1answer
570 views

Timer functionality in Python

I am trying to implement Elapsed Timer in Python (version 3). The clock and time methods in Python seems to have different ...
3
votes
1answer
727 views

Trying MVVM on timer app

Check me: Model should do everything. That's where all functionalities and features are accommodated. It has some properties, that I can access and use. ...
2
votes
1answer
734 views

Matlab tic and toc commands implemented in C++

I need to time a few functions that I'm implementing, so I decided to implement a way of timing even multiple or sub calls based on the stack data structure and on the ...
3
votes
2answers
2k views

Watchdog in Golang

I am new to Go. I am trying to implement a simple watchdog. It calls a function once after a certain delay has elapsed; kicking it resets the delay. Kicking it after the function has already been ...
7
votes
3answers
540 views

Visitor Pattern/Leaky Bucket variant implementation to run an operation at a certain interval

My code is a variant on the Visitor Pattern and a "leaky bucket" variant. The goal is pretty straightforward: the "bucket" will collect a specified number of items (say, for example, 500) and then ...
2
votes
1answer
386 views

Implementing a Rubik's Cube timer and scrambler in console

Related, but in C++ I have written a program that generates scrambling algorithms for and times a solving session of a 3x3 Rubik's cube. Requirements for scramble and timer The same face cannot be ...
6
votes
1answer
1k views

Single-threaded timer

I've created a System.Threading.Timer wrapper in C#. The tasks to be triggered when the timer elapses have highly variable execution times. My design criteria are: ...
2
votes
1answer
2k views

A clock implemented using Moment.js

This is a POC for a clock using moment.js, eventually I plan to recreate this in Raect.js. Any opimisations or a better way to do it? ...
1
vote
0answers
117 views

Timer class to measure time differences

Here is my Timer class code, and the context it is being used in. How accurate is the timer for measure elapsed time? ...
1
vote
1answer
75 views

Countdown module that hides an element when a specified date is reached

I have the following piece of code which hides an element when a specified date was reached. I would like to get some tips about do's and don'ts. Specifically, I'm interested in: improvements ...
4
votes
1answer
51 views

Babysitting a server reboot

I'm looking to improve a loop within a script that performs scheduled server restarts. Currently, I'm using a DO While loop with an exit condition within an IF statement once a counter reaches a ...
1
vote
2answers
2k views

Countdown Timer for Tests

I created this countdown timer as a tool to count down the remaining time on a test a few months ago. However, I looked at the code today and it looks like it needs some improvement, but I'm not sure ...
4
votes
3answers
8k views

Easy-to-use C++ class for asking current time stamp in milli-, micro- and nanoseconds

I have to benchmark my code often, and decided that it is about time to implement an easy API for that: current_time.h: ...
8
votes
4answers
3k views

Pomodoro Timer in Python

I wrote a simple Pomodoro Timer in Python 3: ...
3
votes
3answers
244 views

Helper utilities for easier benchmarking in C

I have this tiny library for measuring the execution time in milliseconds and returning the duration plus the result: execres.h ...
8
votes
1answer
211 views

Pomodoro timer in Go

My goal is to implement a simple pomodoro timer using Go: channels, goroutines. I'm newbie in Go world and have some misunderstanding about naming convention. I read a lot of Docker's code on GitHub ...
2
votes
1answer
2k views

Custom countdown timer class to replace the Android CountdownTimer

This project was made to replace the stock Android CountdownTimer class. It is more responsive when completing the timer and adds additional functionality such as ...
5
votes
2answers
1k views

Android splash screen

I have implemented a splash screen, to hold/pause the screen for few seconds and then launch the next screen. I am very enthusiastic to know if there is a more basic way to write the code. ...
5
votes
1answer
390 views

CountDownTimer that responds to clicks

The app: Creates CountDownTimers and displays them in a simple layout. The user can choose how long the timer should be through SharedPreferences and a settings activity. Each timer has a preparation ...
8
votes
2answers
2k views

Portable periodic/one-shot timer thread - follow-up

This is a much improved version (I hope) of code in this previous code review of mine. I have: renamed several things. Are the names good? made it lazily start the worker thread only after the first ...
4
votes
2answers
500 views

Sleep with count down display

I have a sleep function which displays the time remaining in sec, some feedback would be appreciated ...
3
votes
1answer
38 views

JavaScript idle managing structure

I am just getting into the world of javascript, coming from the world of classical inheritance. The following is a library I wrote to track when a webapp is idling and I wrote it like I write ...
1
vote
1answer
86 views

A small timer in C

I needed to make a timer to profile small programs a while back. My use wasn't for a major project or mission critical code or anything even remotely close to that, just for personal learning ...
5
votes
2answers
4k views

StopWatch app in android

Activity ...
3
votes
1answer
660 views

Detecting the duration of a button press in a microcontroller project

I'm a C++ newbie and so far have written my code mostly in an not OO way. Since this is getting confusing I'd like to start creating libraries for some of the functionalities that I've implemented. ...
3
votes
1answer
994 views

XCTestCase#waitFalseExpectationUntilTimeout implementation

I am working on an iOS project and I'm in charge of testing most parts of it. As I write some tests, I often have the need to wait for an asynchronous method to finish, and then test that something ...
5
votes
1answer
2k views

Basic game engine: timer, FPS and logic loop

I'm creating a simple Java game engine (just for fun). The idea is to create a basic framework for developing any kind of 2D game, an abstract engine that does the hard work. Would you like to review ...
4
votes
1answer
1k views

Simple load testing script in bash

Here's the code ...
4
votes
3answers
10k views

A reusable AJAX polling function

I have written a small JavaScript function which performs an AJAX request every x seconds. I was hoping some of you could give it a look over and give me any pointers on redundant code or bad ...
6
votes
1answer
227 views

Script to pick random answers for a vocabulary quiz

I am making a small script, which, when run in the console on Vocabulary.com, picks one answer (the third or fourth) and clicks. Then the code checks if the answer was wrong or right and goes to the ...
7
votes
1answer
1k views

Chess countdown timer for Arduino LCD Keypad

I'm very new to C++ and Arduino, with a background in Python. I've written this code for a countdown timer and a simple menu to set the time available to each player, using button handling code from ...
4
votes
2answers
188 views

Event timers database interaction layer

I've just started with the basics of OOP. At first it looked complicated, but once I just started with it, it seemed so easy and everything seems to work like a charm, and that's why I'm unsure if I'm ...
1
vote
2answers
150 views

Lower the volume of my computer over time in Python

I wrote a program to gradually lower the volume of my computer when I go to sleep so I can fall asleep with TV or music on. This was my first time using argparse and I feel like there should be a ...
3
votes
1answer
9k views

Custom countdown second timer

I'm making a card game and I found useful to include a 60 second countdown timer. Here is my approach: ...
1
vote
0answers
57 views

Restarting properly

I have an activity with a timer in it, which starts an activity when the timer goes down. Before, when onPause() would get called after a phone call, my activity ...
1
vote
0answers
1k views

Millisecond timer using plain standard C++98

For development I'm using timer classes that are based on Win32 functions like QueryPerformanceCounter() or the time stamp counter of Intel-compatible CPUs. However,...
3
votes
2answers
231 views

setTimeout and setInterval

Problem statement After 10 sec of execution of a program, start reading the property descriptors of each property of an object and continue reading all remaining properties each, every 3 seconds ...
5
votes
1answer
4k views

Minimalist countdown timer with C#

I'm looking to add a module to one of my utility classes that functions as a countdown timer for tools that execute tasks after a certain amount of time. The code below is what I have working for PoC, ...
3
votes
0answers
40 views

Periodically monitor if record is not updated using Node, Event and setTimeOut

Here is my scenario: Every user checks in every five minutes. If some user doesn't check in after 5 minutes, I should be able to keep track of it. If some user doesn't check in N number of times, an ...
12
votes
4answers
3k views

Rubik's cube timer & scrambler

This uses a linked list to store the data. I used a linked list as it's the only type of data structure that I know currently. Using chrono, I can get microseconds ...
11
votes
1answer
1k views

Precise timings with low jitter via RDTSC (for x86 and x64)

The Win32 API has a so-called 'high performance counter' (QueryPerformanceCounter() and friends) but often it is neither precise enough nor reliable enough, due to ...
5
votes
1answer
10k views

Executing periodic tasks

I am writing a code in Golang to execute a periodic function (every 2 second). According to documentation and an example I have written two programs. Can anybody tell which one is better? Also, is ...