timer

How to go about speed testing my PHP script?

I have a script that is running slowly and I was wondering how I could time it and see which fixes improve the speed. Is there some sort of a PHP timer? Update: Thought I should clarify... The script that is running slowly is my mailing list script that sends an email to everyone on the list. So I am looping through an array of subscrib...

Is the HPET directly accessible in Windows?

I would like to use the High Performance Event Timer (HPET) for an profiling tool to take very high precision measurements, quickly. timeGetTime does not provide sufficient resolution at 1ms, and QueryPerformanceCounter is much slower per read than I'd like. I came across the HPET while researching the problem, but I can't see any sample...

Execute an operation every x seconds for y minutes in c#

Hello, i need to run a function every 5 seconds for 10 minutes. I use a timer to run it for 5 secs, but how do I limit the timer for only 10 mins? Thank you very much Andrea ...

How to ensure that a winform closes in exactly X seconds

In my WinForms application, I need to pop up a little custom dialog that stays on the screen for X amount of seconds and then disappears. So I use a System.Threading.Timer to invoke the _dialog.Close() method once the appropriate amount of time has elapsed. This of course means that I have to do the whole "if InvokeRequired BeginInvoke...

Java - Scheduling a daily task

I'm looking for an effective way to execute a method everyday at 3PM regardless of when the application was initially run or how long it has been running. This must be done entirely from the application with no OS intervention (ex. Windows Task Scheduler) I have been experimenting with java.util.Timer in varies configurations but I hav...

How to block a timer while processing the elapsed event?

I have a timer that needs to not process its elapsed event handler at the same time. But processing one Elapsed event may interfere with others. I implemented the below solution, but something feels wrong; it seems like either I should be using the timer differently or using another object within the threading space. The timer seemed ...

Animation: Timer vs Idle

There is a similar thread else where, but it focues on gameprogramming which I find a little different to regular gui applications with some 'extra sugar'. What would be the right approach for driving small gui-animations (like expanding/collapsing panels, glowing buttons etc)? Would it be best to setup a timer to fire at regular inter...

VB.NET Timer question

Guys, I wrote a VB.NET Windows Service, which works fine. I have only one issue with it. I want the service to execute on the half hour and top of the hour marks (e.g. 9:00, 9:30, 10:00, 10:30, 11:00, etc etc etc). I am using the following code: Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your s...

Start Thread with a given execution time

My main process calls an external library method. This method sometimes hangs. I can not fix the external library because another company is responsible for it. I want to use a Thread for the library calls with a defined execution timer. When the method call takes to long, the Thread with the Runnable in which the method call is placed ...

Timer in Silverlight

Is there another Timer object that can be used in Silverlight except for the System.Threading.Timer object? ...

C Timer Callback

Interested in something similar to JavaScript setTimeout in C on both UNIX and Windows. Basically, I want: start_timer(&function_pointer, int time_in_secs) or as close to that as I can get. Also, something similar to setInterval would be nice (where it calls the callback every n seconds), but that can be implemented using setTimeout...

Timer vs Thread primitive in Java

Has anyone observed that creating a thread that does work in a while(true) loop with a Thread.sleep(t) appears to consume more CPU than creating a Timer in Java with a wakeup of t? Anyone with JVM expertise know why this is? I've only really tried this on Windows and Linux x86. ...

Efficient Timer Algorithm

What is the best algorithm to implement a simple timer library. The library should allow the following: Timers to be started Timers to be stopped Timers to be checked whether they are still running On Timer expiry a callback function will be called. The timer module will allow timers to have a time resolution of Ns and the module sh...

C++ class - Increment and decrement attribute every N milliseconds

Hello all! This must be an easy question but I can't find a properly answer to it. I'm coding on VS-C++. I've a custom class 'Person' with attribute 'height'. I want to call class method Grow() that starts a timer that will increment 'height' attribute every 0.5 seconds. I'll have a StopGrow() that stops the timer and Shrink() that de...

How do you unit test classes that use timers internally?

Like it or not, occasionally you have have to write tests for classes that make internal use of timers. Say for example a class that takes reports of system availability and raises an event if the system has been down for too long public class SystemAvailabilityMonitor { public event Action SystemBecameUnavailable = delegate { }; pub...

How reliable are .net timers?

I'm looking at using a System.Timers.Timer in a windows service. I would like to know how reliable and accurate they are. In particular: Are there any guarantees about how often they will run? What happens when the processor or memory are overloaded? Will the ElapsedEventArgs.SignalTime always be accurate under such circumstances? ...

Registering for timer elapsed events

I want to create a class that initializes a timer which will be used as a central core for other class members to register themselves for the timer elapsed event. My problem is that I don't really know how to expose the timer elapsed event to other classes. One solution, that I think might work is that I simply expose the timer as a publ...

Modifying a Swing Timer's Delay during Runtime

I'm developing a Queue simulation, using a Swing Timer to dequeue objects after certain amounts of time. The interval is determined by peeking at the next object in the queue, getting an integer from it, and setting the delay of its corresponding timer. Here's the relevant snippet from the program (Note: _SECONDS_PER_ITEM is a constant ...

What is the best way to exit out of a loop after an elapsed time of 30ms in C++

What is the best way to exit out of a loop as close to 30ms as possible in C++. Polling boost:microsec_clock ? Polling QTime ? Something else? Something like: A = now; for (blah; blah; blah) { Blah(); if (now - A > 30000) break; } It should work on Linux, OS X, and Windows. The calculations in the loop are for up...

How to have a WPF binding update every second?

I want to show the user how many seconds have passed since some event occurs. Conceptually, my view model has properties like this: public DateTime OccurredAtUtc { get; set; } public int SecondsSinceOccurrence { get { return (int)(DateTime.UtcNow - OccurredAtUtc).TotalSeconds; } } If I bind a TextBlock.Text property to SecondsSi...