How To Create a Really Accurate Timer

Some of the work on my current project requires accurately timing events, at a frequency of a few dozen per second (that means that each event has to follow the previous one within a few milliseconds). The resolution of those calls is so small, that even System.Threading.Timer can not handle it and lags behind.

After some searching, I found that Win32 Multimedia Timers are a good solution to this problem, as they are (probably) the timers with the highest resolution available on the platform. At the moment, there is no official wrapper for the API in the Framework and Leslie Sanford's article offers a nice implementation.

Advertisements

4 thoughts on “How To Create a Really Accurate Timer

  1. Would developers be aware that there is a limitation of up to 16 MM timers per process. Would developers also be aware that all these 16 MM timers would be using the same SINGLE thread to fire their events. Would developers also be aware that having 16 MM timers firing within, say, 2ms frequency, would seriously hinder the performance of the system.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s