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.

learn more… | top users | synonyms

6
votes
1answer
63 views

Updating the UI with a timer - code intended to help teach

I thought it would be helpful to put together an example of what I'm talking about in the second part of my answer to this stackoverflow question. The idea is that there's some data that is updated ...
3
votes
1answer
67 views
2
votes
0answers
27 views

Pausing a SwingWorker with a Timer

I made a SwingWorker which is fetching tweets using the twitter4j API. The twitter API will allow 180 queries every 15 minutes, and then throw an exception with ...
7
votes
2answers
76 views

Exception handling for HTTP request timer

This method is used to check a URL and return the time it takes to check and the HTTP status code: ...
1
vote
2answers
146 views

Simple web alarm clock

I decided to strengthen my "vanilla JavaScript" skills since I've lately been getting more into jQuery and just discovered the potential of node.js. As a result, I decided to make a basic alarm clock ...
2
votes
1answer
43 views

Rewrote my benchmark/timer library

I created a timer library called PHPBenchTime a few years ago, and decided to rewrite it last week. This new version is meant to add in missing functionality (pause/unpause) as well as expand on the ...
11
votes
5answers
453 views

Stopwatch template

It's often useful to be able to time code, for instance, to evaluate alternative approaches to the same problem. Because this is a thing I use frequently, I have created this Stopwatch templated ...
8
votes
2answers
61 views

How can I make this userform timer faster?

I have a userform that displays a goal time for workers to shoot for when completing a task. It also has a stopwatch on it that is controlled by a start, stop, and reset button on the userform. If the ...
4
votes
1answer
86 views

Inefficient Stopwatch - revised

This is my revised code of Stopwatch: ...
5
votes
1answer
115 views

Inefficient Stopwatch

I have just finished a simple GUI stopwatch, but some of its code looks like it needs replacing. This is the code: Clock class (extends Thread): ...
3
votes
1answer
73 views

Winforms Graphical Timer Control

This is a Graphical Timer control I made for C# Winforms, which taught me quite a bit (it is my first Custom Control). The code below is a fully working application with the Graphical Timer, some ...
10
votes
3answers
702 views

Basic timer from one minute to 0

I'm a beginner in JavaScript and I am sure that there is a better way to do it (basic one minute timer from 01:00 to 00:00 running from pageload): JSFiddle ...
5
votes
1answer
169 views

Simple timer class for game model

I have a simple strategy game, and I implemented a simple counter object to count down a number whenever the game ticks. I have heard about something called NSTimer but I haven't messed with it at ...
3
votes
1answer
74 views

Schedule Global Task by using static System.Timers

I'm using System.Timers to schedule tasks. I find this working, but I'm not quite sure if it's ok to do it this way. ...
6
votes
1answer
229 views

Program to shutdown computer after a certain time

I'm trying to make a program that will shutdown my computer after a certain time that I will input via GUI. I'm wondering if I did it the correct way. Also, will this slow down my computer while it ...
4
votes
2answers
113 views

Iterate through series of timers

I wrote a short program for my exercise routine. It takes a JSON array of exercise names and duration (seconds) and puts it on the screen. The JSON looks like this: ...
4
votes
2answers
88 views

Measuring Execution Times

I was wondering which time.time() of from datetime import timedelta was the quickest and best way to find how long a programme ...
5
votes
1answer
48 views

Does this code actually give a valid representation of how quick a system is?

So I wrote this code a while ago as a way of seeing how many times it could compute a simple sum in a second (one tick). I was wondering if this gives me valid results or is in fact giving me bogus ...
7
votes
1answer
110 views

Touchless lightswitch with Raspberry Pi

I am currently developing a touchless lightswitch via a Raspberry Pi, an ultrasonic module and a nice radio module. However, I am quite a beginner in Python and it was a hard time (at least for me) ...
20
votes
9answers
2k views

Countdown Code: 'League of Legends'

I have written some code to track buffs as a side addition to the popular game League of Legends. My code is incredibly repetitive and I also have the issue of not being able to track multiple buffs, ...
10
votes
3answers
157 views

Is this timer efficient?

I found myself writing code to run at a specified frequency more than once, so I decided to make this simple timer. My main concern is that this is not the most efficient way of doing this since with ...
0
votes
0answers
62 views

Learning using Neural Network

This is my code for MLP backpropagation. ...
7
votes
1answer
140 views

Timer utilizing std::future

I have a Timer class executing a function in a specified interval: ...
3
votes
1answer
56 views

Utility object for setTimeout

I was using setTimeouts for a project where a callback will be called after a duration, but the user has the options of extending, pausing or stopping the timeout. I felt using the default setTimeout ...
2
votes
1answer
45 views

Auto change page title while bookmarking a page

Here is what I'm trying: Please review the code: ...
4
votes
1answer
543 views

Simple Multithread Timer

This is a very basic timer that can support multithreading with std::thread and std::chrono. The timer has the classic ...
6
votes
2answers
1k views

Portable periodic/one-shot timer implementation

I have implemented a class that provides portable one-shot or periodic timers. The API provides a way to schedule one or more timer callbacks to fire some number of milliseconds in the future, and ...
6
votes
2answers
1k views

Java GUI code with Swing Timer

I have the following questions for the below code: Is there a simpler implementation of an on-screen counter? I made CountTimer inner class since it's tightly ...
1
vote
2answers
522 views

Countdown timer

Being new to raw JavaScript, intervals and times this was not the easiest script to come up with, and thus, although it seems to be working as I want it too the code looks very clunky. The timer ...
1
vote
1answer
301 views

Executing method on a certain interval + offset

I would like to execute a certain method at a given interval. The reason why I can't use a timer + its event handler right away is because I want to add an offset to each tick (100ms in my example ...
5
votes
1answer
208 views

Listening for values changed by the memory

I'm fetching some values from the memory. I would like to create some custom events that I can listen to for each value. Since there are no existing events regarding memory changes, I've decided to go ...
1
vote
2answers
4k views

Time of day based timer - run function at certain time, daily

I need to call a function exactly at certain hour, daily, my programs runs 24/7. I wrote the following timer mechanism, which generally works that way: Calculate time until hour and generate timer ...
5
votes
1answer
241 views

Is this kitchen timer code pythonic?

I've been doing bits and bobs with Python for a few years, but I've never took the time to get feedback on what's pythonic and what's not. In the interest of collaborating more with Python ...
2
votes
2answers
227 views

Timer factory fn optimization

I use this Timer function quite a bit lately for all sorts of stuff, and would appreciate if someone could review/analize/criticize/verify and, of course, suggest things I can do to optimize it for ...
0
votes
1answer
122 views

Ping and write the status of a timer on a GUI thread

I am running a timer for updating some of my operations, such as buffers. But I also want ping to be added. It is added, but I think it can be improved. This is because I think it's running on the ...
7
votes
1answer
349 views

Timing analysis of many test cases in Python

I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better ...
1
vote
1answer
397 views
6
votes
1answer
68 views

Timed requests and parsing JSON in Python

I wrote this tiny script to pull the JSON feed from the CitiBike website: ...
2
votes
1answer
206 views

Opinions/Improvements on a run periodically/timer function in Python 2.7

I'm looking for some opinions on this bit of code that I wrote and if there are any ways it can be improved. The scripts aim is to run the function runme() every 60 seconds with a random interval ...
6
votes
1answer
812 views

How to make this ping test with timer more efficient?

I wrote a small ducktaped VBA script which pings servers every 15 mins or so. If a server's status is anything other than "Alive", the server and timestamp is written to another worksheet called ...
2
votes
1answer
1k views

Java - Is this the correct implementation of a timer/timertask to destroy a process that overruns a defined time limit

I was wondering if this is the correct implementation of a times task to destroy a thread after it overruns a predefined time period: it works by creating a getting the thread from ...
4
votes
2answers
4k views

Timer Tick Event only to execute at specific time

I have a timer that is only supposed to tick between x and x on weekdays. I have used the following implementation. ...
4
votes
1answer
220 views

Managing a stopwatch mobile app

I'm using the following pattern in my mobile app. The code snippet below manages a stopwatch. Is there a way to simplify the code for better readability and probably getting away from needing to use ...
8
votes
1answer
2k views

The correct (and safe) way to use a Timer to poll a Delegate

This is a followup to Polling loop to run in a background thread where I was initially using a single thread and Thread.Sleep() to poll a delegate. I was ...
1
vote
1answer
125 views

Timed series of events. Logic for organizing events based on time? [closed]

I would like to execute a series of events at the time at which they occur. The events are stored in a list and always sorted by time of execution. ...
1
vote
1answer
639 views

Timer implementation

I have a Visual Studio 2008 C++03 project where I need a timer. I have an implementation that works well, but I'd like any general suggestions from the community on how to improve it. (More generic, ...
1
vote
1answer
310 views

Timer wrapper review

I used this code in several projects. But I am not sure if it is stable. However on production it is working well, but I want to listen your advices: ...
2
votes
3answers
3k views

Timer class for games

I've tried to write a simple timer class that could later be used in games, such as for updating the screen every second. Problem is, I read gettimeofday() was ...
5
votes
4answers
4k views

Linux C++ Timer Class: How can I improve the accuracy?

I wrote this class today, but I am trying to figure out how to make it more accurate. I pass in seconds and multiply by 1000 to make it milliseconds, and the time does not line up. I need the ability ...
5
votes
1answer
1k views

Timer framework in C

I am trying to create a very simple timer framework which allows you to setup event handling based on a timeout. The basic primitives allow the programmer to: allocate or free timers arm/disarm ...