C# - time.ticks

Started by
1 comment, last by pimple 19 years, 6 months ago
hello... here's what i'm working on: http://www.geocities.com/antigatez/RigoLib/running.zip anyhoo, that's just the animation part of my project, but i'm both moving the character and animating the sprite based on my counter (using standard Borland C# Builder's counter)... i know how to do both of these things based on time, but i'm not sure what the best way to get the time in C# is... anyone? thanks!
---Current project - Duck Hunt 2: Free at Last!http://www.duckhunt2.cjb.net
Advertisement
Pimple, it depends on how accurate of a resolution you need on the counter. If it doesn't need to be extremely precise, you can simply use DateTime.Now.Ticks. However, if you need to be more accurate than DateTime.Now.Ticks can provide (Windows XP: 10 millisecond resolution; Windows 98: 55 millisecond resolution, I believe), then you will need to resort to using kernel functions like so:

        [System.Security.SuppressUnmanagedCodeSecurity]        [DllImport("kernel32")]        public static extern bool QueryPerformanceFrequency(ref long PerformanceFrequency);        [System.Security.SuppressUnmanagedCodeSecurity]        [DllImport("kernel32")]        public static extern bool QueryPerformanceCounter(ref long PerformanceCount);



I hope this helps! :)
Jason Olson - Software Developer[ Managed World ]
those kernel calls... heh, thanks! that's just what i was looking for...
---Current project - Duck Hunt 2: Free at Last!http://www.duckhunt2.cjb.net

This topic is closed to new replies.

Advertisement