timer

Reliable Timer in a Console Application

I am aware in dot net there are three timer types (see http://msdn.microsoft.com/en-us/magazine/cc164015.aspx). I have chosen a the threaded timer as the other types can drift if the main thread is busy and I need this to be reliable. The way this timer works in the control of the timer is put on another thread so it can always tick alo...

Is gettimeofday() guaranteed to be of microsecond resolution?

So I find myself porting a game that was originally written for the Win32 API to Linux (well, porting the OS X port of the Win32 port to Linux), and have implemented QueryPerformanceCounter by giving the uSeconds since the process start up: BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount) { gettimeofday(&currentTime...

Timer-based event triggers

I am currently working on a project with specific requirements. A brief overview of these are as follows: Data is retrieved from external webservices Data is stored in SQL 2005 Data is manipulated via a web GUI The windows service that communicates with the web services has no coupling with our internal web UI, except via the database....

Sharepoint: executing stsadm from a timer job + SHAREPOINT\System rights

Hi, I have an unusual situation in which I need a sharepoint timer job to both have local administrator windows privileges and to have SHAREPOINT\System sharepoint privileges. I can get the windows privileges by simply configuring the timer service to use an account which is a member of local administrators. I understand that this is not...

Getting accurate ticks from a timer in C#

I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in .NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough. For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every .5 seconds (or 500 milliseconds). ...

Unit testing a timer based application?

I am currently writing a simple, timer based mini app in C# that performs an action n times every k seconds. I am trying to adopt a test driven development style, so my goal is to unit test all parts of the app. So, my question is: Is there a good way to unit test a timer based class? The problem, as I see it, is that there is a big ri...

Is DateTime.Now the best way to measure a function's performance?

I need to find a bottleneck and need to accurately as possible measure time. Is the following Code Snippet the best way to measure the performance? DateTime startTime = DateTime.Now; // Some Execution Process DateTime endTime = DateTime.Now; TimeSpan totalTimeTaken = endTime.Subtract(startTime); ...

How scalable is System.Threading.Timer?

I'm writing an app that will need to make use of Timers, but potentially very many of them. How scalable is the System.Threading.Timer class? The documentation merely say it's "lightweight", but doesn't explain further. Do these timers get sucked into a single thread (or very small threadpool) that processes all the callbacks on behal...

Resettable Java Timer

I'd like to have a java.utils.Timer with a resettable time in java.I need to set a once off event to occur in X seconds. If nothing happens in between the time the timer was created and X seconds, then the event occurs as normal. If, however, before X seconds has elapsed, I decide that the event should occur after Y seconds instead, th...

Rollover safe timer (tick) comparisons

I have a counter in hardware that I can observe for timing considerations. It counts miliseconds and is stored in a 16 bit unsigned value. How do I safely check if a timer value has passed a certain time and safely handle the inevitable rollover: //this is a bit contrived, but it illustrates what I'm trying to do const uint16_t print_in...

Assembly CPU frequency measuring algorithm

What are the common algorithms being used to measure the processor frequency? ...

What tools are there for timed batch processes in J2EE?

Hello, my employer just asked me to run a timed batch process in a J2EE websphere application they have running. It's supposed to run a certain class at 1130 pm everyday. I'm not very familiar with J2EE nor websphere server (or tomcat, in the develpment environment), and I've been digging around but all I've found is about the java time...

Highest resolution "Sleep" for IA32/Wintel?

Howdy Overflowites, I'm looking to see if anyone knows of a higher-resolution "Sleep" API than can be achieved using the following code block: ::timeBeginPeriod( 1 ); ::Sleep( 1 ); ::timeEndPeriod( 1 ); I'm trying to accomplish some "process balancing" work, and after some experimenting, find I need finer grain control than the...

How to access the HttpServerUtility.MapPath method in a Thread or Timer ?

Hi, I use a System.Timers.Timer in my Asp.Net application and I need to use the HttpServerUtility.MapPath method which seems to be only available via HttpContext.Current.Server.MapPath. The problem is that HttpContext.Current is null when the Timer.Elapsed event fires. Is there another way to get a reference to a HttpServerUtility obje...

ASP.NET and Timers

Consider this code... using System.Threading; //... Timer someWork = new Timer( delegate(object state) { //Do some work here... }, null, 0, 60000); HttpContext.Current.Application["SomeWorkItem"] = someWork; Could this be dangerous? Caching a timer in the Application to perform some work in the background while yo...

Is there a good lightweight multiplatform C++ timer queue?

What I'm looking for is a simple timer queue possibly with an external timing source and a poll method (in this way it will be multi-platform). Each enqueued message could be an object implementing a simple interface with a virtual onTimer() method. ...

In JavaScript, is there a source for time with a consistent resolution in milliseconds?

The Date object in javascript performs differently machine to machine and browser to browser in respect to the function's resolution in milliseconds. I've found most machines have a resolution of about 16 ms on IE, where Chrome or Firefox may have a resolution as good as 1ms. Is there another function available to javascript in general...

How does any application (chrome, flash, etc) get a time resolution better then the system time resolution?

This article on microsoft's tech net site supplies an exe that will calculate your windows machine's minimum time resolution - this should be the smallest "tick" available to any application on that machine: [http://technet.microsoft.com/en-us/sysinternals/bb897568.aspx][1] The result of running this app on my current box is 15.625 ms....

How do I obtain CPU cycle count in Win32?

In Win32, is there any way to get a unique cpu cycle count or something similar that would be uniform for multiple processes/languages/systems/etc. I'm creating some log files, but have to produce multiple logfiles because we're hosting the .NET runtime, and I'd like to avoid calling from one to the other to log. As such, I was thinking...

.NET Timers: Whats is the best way to be notified in X seconds?

Suppose I have a non-recurring event that needs to be raised X seconds from now such as a timeout. Intuitively it would make sense to create a System.Timers.Timer, set its interval to X*1000, wire its tick up to the event and start it. Since this is a non-recurring event and you only want it raised once you would then have to stop the ...