Skip to content

AcTiViSioN911/HighPrecisionTimer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HighPrecisionTimer

A high precision timer in .NET

There are often times where people would like regularly spaced events at a resolution greater than C# and Windows can normally provide (~15ms). This is a limitation of the standard timer mechanisms built into the Windows OS. There do exist high precision timing APIs for multimedia applications, but these are not exposed via .NET APIs. For applications that need timer event precision on the order of 1ms, these APIs are useful. This library is a quick example of using the Multimedia Timer API.

I will note that this API changes system wide settings that can degrade system performance (esp battery life), so buyer beware. Since Windows is not a real-time OS, the load on your system may cause the MM timer be delayed resulting in gaps of 100 ms that contain 100 events in quick succession, rather than 100 events spaced 1 ms apart. Some additional reading on MM timers.

I originally posted the code as an answer to a question on Stack Overflow

About

A high precision timer in .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%