Questions tagged [timer]

Timer is a component that has the functionality to trigger a user defined action at regular intervals as configured by the user.

Timer is a component that has the functionality to trigger a user defined action at regular intervals as configured by the user.

Some timers (such as Java Swing timer, WPF DispatcherTimer, WinForms Timer) are also capable of firing they events in GUI thread so there is no need to switch into this thread in order to update the components. Other timers do not have this capability and are more optimized to handle big number of scheduled events.

Depending on how does the scheduler behaves if the new even should be fired when the current event has not yet been fully processed, the timer may be coalescing or non coalescing. A coalescing timer reduces multiple pending events to a single event, reducing the number of events to handle. A non-coalescing timer fires pending overtime events in rapid succession with no delay between them, in order to catch up.

19566 questions
34
votes
3 answers

Can you implement a timer without a "sleep" in it using standard c++/c++11 only?

IMPORTANT UPDATE Note: since this question is specifically about timers, its important to note there is a bug in gcc that if you are using std::condition_variable::wait_for (or wait_util) it uses the system clock even if you pass it a…
code_fodder
  • 15,263
  • 17
  • 90
  • 167
34
votes
4 answers

Throwing exceptions in callback method for Timers

I was unable to find an answer to this question anywhere... What happens with the exceptions thrown in the callback method for System.Threading.Timer, (or in the event handler for System.Timers.Timer). Is the exception propagated to the thread on…
Kornelije Petak
  • 9,412
  • 15
  • 68
  • 96
33
votes
7 answers

Xcode Objective-C | iOS: delay function / NSTimer help?

So I'm developing my first iOS application and I need help.. Simple program for now, I have about 9 buttons and when I press the first button, or any button, I just want the first button to highlight for 60 milliseconds, unhighlight, second button…
Retro
  • 333
  • 1
  • 3
  • 5
33
votes
6 answers

calling a method after each 60 seconds in iPhone

I have created an GKSession and as its object is created, it starts search for availability of devices, as - (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state { I want to call this method after…
Chatar Veer Suthar
  • 15,541
  • 26
  • 90
  • 154
33
votes
5 answers

SpriteKit - Creating a timer

How can I create a timer that fires every two seconds that will increment the score by one on a HUD I have on my screen? This is the code I have for the HUD: @implementation MyScene { int counter; BOOL updateLabel; SKLabelNode…
user3578149
  • 475
  • 1
  • 5
  • 11
33
votes
6 answers

Timer in Portable Library

I can't find a timer in portable library / Windows Store. (Targeting .net 4.5 and Windows Store aka Metro) Does any have an idea on how to created some kind of timing event? I need somekind of a stopwatch, so this should refreshn once a second or so
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
33
votes
3 answers

How to use QTimer

In Qt I'm trying to set a QTimer that calls a function called "update" every second. Here is my .cpp file: #include "mainwindow.h" #include "ui_mainwindow.h" #include #include "QDebug" MainWindow::MainWindow(QWidget *parent) : …
Frank
  • 2,446
  • 7
  • 33
  • 67
33
votes
2 answers

If mouse over for over 2 seconds then show else don't?

Here is a jQuery slide function I have applied to a div on hover in order to slide a button down. It works fine except that now everytime someone moves in and out of it, it keeps bobbing up and down. I figured if I put a one or two second delay…
user1266515
  • 796
  • 3
  • 15
  • 33
32
votes
5 answers

Launch a local notification at a specific time in iOS

I am trying to create a timer which triggers a local notification to go off at a time that the user has set. The issue I am having is that I cannot figure out a way to be able to set the local notification to go off at say 7:00PM. Almost all the…
imjonu
  • 515
  • 1
  • 6
  • 12
32
votes
9 answers

need to call a function at periodic time intervals in c++

I am writing a program in c++ where I need to call a function at periodic time intervals, say every 10ms or so. I've never done anything related to time or clocks in c++, is this a quick and easy problem or one of those where there is no neat…
Execut1ve
  • 321
  • 1
  • 3
  • 3
32
votes
3 answers

Windows service with timer

I have created a windows service with timer in c#.net. it works fine while i debug/build the project in visual studio but it does not perform its operation after installation. What might be the reason behind this ? code : public partial class…
Nitin Kabra
  • 3,146
  • 10
  • 43
  • 62
32
votes
4 answers

NSTimer timerWithTimeInterval: not working

I've created a test application with timer before implementing it in my project. It was the first time I'm using timer. But the issue is when I implemented timer using [NSTimer timerWithTimeInterval: target: selector: userInfo: repeats: ]; , it is…
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
32
votes
6 answers

Using System.Windows.Forms.Timer.Start()/Stop() versus Enabled = true/false

Suppose we are using System.Windows.Forms.Timer in a .Net application, Is there any meaningful difference between using the Start() and Stop() methods on the timer, versus using the Enabled property? For example, if we wish to pause a timer while we…
Stewart
  • 4,223
  • 6
  • 31
  • 39
31
votes
1 answer

Spawning threads in a JSF managed bean for scheduled tasks using a timer

I would like to know if it's ok to use Timer inside application scoped beans. Example, lets say that I want to create a timer task that sends out a bunch of emails to every registered member one time per day. I'm trying to use as much JSF as…
Dimman
  • 1,186
  • 4
  • 14
  • 21
31
votes
3 answers

WPF .NET Best way to trigger an event every minute

I have an app that needs to check a database table every minute. The table is indexed by the time of day and so the app needs to run this check every minute. What's the best of way of doing this? I can create a background worker thread but if I…
Simon Temlett
  • 2,397
  • 2
  • 17
  • 17