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
0 answers
82 views

A version of the Pebble Big Time watch face that also displays the date [closed]

I'm seeking style pointers, bugs, memory leaks, incorrect usage etc. ...
Kevin's user avatar
  • 31
3 votes
1 answer
3k views

MyTimer based on QTimer

I needed a timer that fires in intervals for a given duration when e.g. a button is pressed. The button can be pressed several times thus I thought it would be easiest to create a new timer for each ...
463035818_is_not_a_number's user avatar
6 votes
1 answer
241 views

Rate limiting function calls

I wanted to write a function that when applied to another would rate limit it, but permit all calls to eventually make it through. Comments and criticism welcome. ...
52d6c6af's user avatar
  • 672
15 votes
3 answers
3k views

"Ticker" for game timing

I designed a "Ticker" based on how I imagine Minecraft's tick system works. My ticker calls a method tickRate times a second and provides a Delta Time value (...
Jack Wilsdon's user avatar
  • 1,651
7 votes
1 answer
4k views

Timer in pure JavaScript

I was working on a timer code in pure JavaScript and would like to know any pointers to improve: Features Start/ Stop/ Reset on click of a button. Set limit to clock. Update class name for warning ...
Rajesh's user avatar
  • 393
3 votes
1 answer
4k views

A simple analog clock using FLTK

I'm implementing a graphical representation of an "analog clock" with moving hands (seconds, minutes and hours), using mainly2 FLTK facilities and the function ...
Ziezi's user avatar
  • 1,174
4 votes
2 answers
113 views

Auctioneer calling "Going once… going twice… sold!"

I feel like the if-else combination isn't the most optimal and I'm also not sure if I need a loop ...
Max Seifert's user avatar
1 vote
2 answers
13k views

Case of System.Timers.Timer vs System.Threading.Timer

I have a console application that I want to use to send an email notification every day at some time (call it 06:00 local time). To do so at the moment I am using a ...
MoonKnight's user avatar
2 votes
3 answers
1k views

Simple JavaScript timer function

I've written a timer to start when the page loads, and to stop when the user clicks a "finished" button: ...
Carol's user avatar
  • 63
3 votes
1 answer
223 views

Pomodoro Timer via setTimeout()

I've made my attempt to code timer entirely by hand using jQuery. No external libraries to manage time at all. ...
Ketus's user avatar
  • 163
4 votes
1 answer
508 views

Creating a Tomato Timer

I have completed a FreeCodeCamp exercise to create a tomato timer and chosen to do so with vanilla Javascript. Although it works, I don't like in how many places I am checking against two state ...
Dan's user avatar
  • 143
3 votes
1 answer
327 views

Javascript: timer function

This is a function I made for a timer that counts down and performs a callback at the end. It seems to work fine, but I think the code is not very clean and has some unnecessary bits; also I would ...
cabralpinto's user avatar
3 votes
1 answer
211 views

Ability System in my game

I'm writing a game in C# Monogame, and I've decided to make my project as modular as possible. GitHub At first, I've had a single project with a folder that's separated inside to other folders ...
Giora Guttsait's user avatar
6 votes
1 answer
3k views

Task Reminder - Repeatedly notify every 6 hours

So I'm very much a beginner to Java and Android programming. I've worked a lot more with Python so I might have some quirks from there bleeding into my code here. I'd like a particular focus on ...
SuperBiasedMan's user avatar
4 votes
1 answer
3k views

Pomodoro Timer via setInterval

I'm hoping for some input on if my code is DRY or how I could have made it more efficient. I am pretty new in terms of jQ/JavaScript and this took me far longer than I care to admit. I will post the ...
Donavin's user avatar
  • 41
6 votes
1 answer
107 views

Creating an in-memory ViewCounter that commits to database every 10 minutes

This singleton is responsible for counting every pageview (called Routes in our case) we get by id, until the timer runs out and commits the results to the database in one query. Then the counter gets ...
Thermometer's user avatar
14 votes
2 answers
951 views

A low tech approach to measuring game speed

Whilst developing a game I needed a delay routine capable of doing delays ranging from 0.5 sec to just a few msec. The obvious choice was to use the BIOS delay function 86h on int 15h. In a true real ...
Sep Roland's user avatar
  • 4,408
2 votes
1 answer
2k views

Is a Timer the best way to achieve recursive in Android?

I'm changing the Viewpager items programmatically using mViewPager.setCurrentItem(position); with a regular interval of time recursively. Please tell me if this is ...
Sai's user avatar
  • 171
4 votes
1 answer
695 views

Time spend in scoped timer

I want to check some timing of my (pre-C11) C++ and wrote a class: ...
FooBar's user avatar
  • 173
4 votes
2 answers
854 views

Debounce in Scala

This is my attempt at implementing debounce in Scala without any 3rd party library. How can I improve the code/make it more idiomatic (and any bugs I might have missed)? ...
pathikrit's user avatar
  • 205
5 votes
1 answer
104 views

Abstracting test suite for simple performance evaluation in Java

Today, I sat down to write a tiny performance test to quickly assess a hunch I had regarding an optimization. The resulting code eventually got rather large for my taste; thus I subsequently tried to ...
ikaerom's user avatar
  • 151
8 votes
1 answer
1k views

Portable method of getting time in C

Mac doesn't have the Unix clock_gettime so I am trying to create something that's really portable and only dependent on C. So far I've come across this function: <...
mr oh's user avatar
  • 81
3 votes
1 answer
1k views

Hash table with "Time To Live" elements

Recently, I got a very interesting task: to realize the hash table that works in multi-process server in common memory, each element of which must have a TTL property. It was suggested to implement ...
Kirill Golikov's user avatar
4 votes
1 answer
23k views

Countdown timer in PHP

Using PHP and jQuery, I was able to make this countdown timer. I've searched various books and obviously on Google, but couldn't find this type of approach as used by me here. I sincerely feel there ...
Archit Saxena's user avatar
15 votes
1 answer
56k views

Proper use of timer in windows service

I have following code to use timer (System.Timers.Timer) in windows service. The goal is that new time handler should not occur if previous one didn't finish its job. Here is how I achieve this: <...
user avatar
18 votes
2 answers
1k views

A Nightmare on setTimeout Street

I have script which plays audio, shows/hides elements: ...
user348173's user avatar
2 votes
1 answer
895 views

Reimplementation of Underscore _.throttle

I've built a function that mimics _.throttle (returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per ...
elledienne's user avatar
2 votes
1 answer
1k views

Running alarms in python

My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. ...
computergorl's user avatar
2 votes
2 answers
513 views

Countdown to multiple update times each day

I'm creating an update function to show my users when the next update will be available. I'm using the jQuery countdown plugin to show the time. What is a more efficient way to write this? ...
Rover's user avatar
  • 21
2 votes
3 answers
9k views

Timer stop watch in AngularJS

I wrote a script for a timer. Is there any way to improve the code, with fewer number of lines? JSBIN ...
fruitjs's user avatar
  • 185
4 votes
1 answer
4k views

Full screen countdown display

As a part of a bigger application, I wrote code which creates a display for a countdown of a given time. It is nothing fancy, but I would still appreciate a review. I am especially concerned about: ...
m.cekiera's user avatar
  • 597
9 votes
2 answers
4k views

Simple 3…2…1 countdown in iOS app

I would like to display a 3...2...1 countdown on my iOS app (before to take a picture) but I didn't find an elegant solution. I don't want to make a Countdown app with an NSTimer. For me the important ...
user avatar
3 votes
3 answers
207 views

Functions between certain times of the day

I'm working on something for my school's laptops that will disable videos/games between 8:00 AM and 3:15 PM. Due to the giant time gap, I will not be waiting to see if the code functions properly or ...
thrifus's user avatar
  • 33
6 votes
1 answer
4k views

A thread-safe stop watch utility class

I am writing a stop watch utility class in Java that I want to be thread-safe (concurrent). Here is what I have right now: ...
Martin Tuskevicius's user avatar
0 votes
1 answer
2k views

Timers to use various Task(s)

I am developing a C# program, which performs various tasks in parallel threads. I created a Base task and let all tasks derived from this class execute. I just want to know if this a viable approach ...
Anjali Gupta's user avatar
2 votes
2 answers
1k views

Timer for a Java game

I have a simple game that implements a TimerTask. However, when there's a popup using JOptionPane the timer task doesn't seem to ...
Algebra is Awesome's user avatar
1 vote
1 answer
104 views

DebugTimer design

Summary: I created this DebugTimer class so that I could test performance of code in a much cleaner/shorter syntax. Prior I was using regular timers and wrapping them all in ...
Shelby115's user avatar
  • 1,961
0 votes
1 answer
3k views

Running a function every second

Can someone review my timer class that runs some code every second, please? The void it's calling (runCode) is just a void with ...
Ash Simpson's user avatar
4 votes
2 answers
4k views

Measure a given method's execution time - follow-up

A long time ago, I've written a method that would allow me to measure the amount of time a method takes to run. I've decided to tweak this method and make use of TPL since measuring a method may take ...
Bruno Costa's user avatar
  • 5,566
4 votes
1 answer
778 views

Passing arguments to a SendMail function referenced by addressOf operator

I am trying to send daily mail alert to users based on some timer values. For that I've used Addhandler to call the sendmail() ...
Sujith Karivelil's user avatar
3 votes
0 answers
480 views

A Timer Construct to Simplify Timing Blocks of Code

This is fairly simple, so I'm just looking for ideas on anything that can be cleaned up, places it can be extended, and suggestions regarding style/naming (I'm terrible at naming). It allows you to ...
Carcigenicate's user avatar
2 votes
1 answer
5k views

Golang concurrent HTTP request

I wanted to test the performance of concurrent http request in Go against node.js: ...
Sarita's user avatar
  • 129
5 votes
1 answer
757 views

Basic 30 TPS server loop

I've created a console server which is supposed to update 30 times per second, I'd like you to review it and also I'm curious about the accuracy of the server's loop. ...
Croccy's user avatar
  • 51
11 votes
1 answer
4k views

Beginner stopwatch app

I'm learning Swift and would appreciate any code review suggestions (the more nit-picky, the better). In particular, I'm wondering if there's a more efficient way to format the time in the ...
thumbtackthief's user avatar
3 votes
1 answer
7k views

Inactivity Timeout

I made this piece of code to detect inactivity on different aspects of my app. It is part of a set of pieces to analyze user behavior. Not saying it's ugly, but good looking constructive criticism to ...
rnrneverdies's user avatar
4 votes
1 answer
2k views

New year countdown

Here's some code I wrote quickly to get a nice millisecond countdown going. It displays the number of milliseconds until the new year in whatever timezone is next to be in 2015 are in in huge font, ...
bjb568's user avatar
  • 659
5 votes
1 answer
446 views

Random interval generator for a game

I have been working on a few games which all have a need to create "events" randomly over time. The intervals need to get shorter as time goes on if the event is negative or they need to get longer ...
PatrickSharbaugh's user avatar
8 votes
1 answer
256 views

Stop Watch Application 2.0

After the tips from my previous review. I have come up with these changes: Changed my braces to start on a new line Used the Single Responsibility Principle Return early whenever possible Use a ...
Funlamb's user avatar
  • 619
3 votes
1 answer
111 views

App to give cigarettes through the day

I have this app, that gives you cigarettes through the day, with equal intervals from one another. These are some important variables: wakeUp - is the time, when ...
Sartheris Stormhammer's user avatar
3 votes
2 answers
1k views

Stop Watch application

I've done the difficult dailyprogrammer challenge #2: Your mission is to create a stopwatch program. this program should have start, stop, and lap options, and it should write out to a file to be ...
Funlamb's user avatar
  • 619

1
3 4
5
6 7