Sign in to follow this  

C# - time.ticks

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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! :)

Share this post


Link to post
Share on other sites

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this