mDx Question on Timing

Mykre

Regular
Joined
Jan 10, 2003
Messages
70
Location
Melbourne
I am working on a DirectPlay application and it will include D3D graphics at a later stage. The question I have is in regards to the timer system, What do I use?

At the moment I need a timer that will be used on the server and client that will poll different functions and provide actions on these functions. Do I use the normal system timer in the threading name spaces, or I found some examples of Timers that have been used in Dx apps, ie the one from the samples in the sd, or one that uses the following api calls,

/// <summary>
/// The current system ticks (count).
/// </summary>
/// <param name="lpPerformanceCount">Current performance count of the system.</param>
/// <returns>False on failure.</returns>
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceCounter(out long lpPerformanceCount);

/// <summary>
/// Ticks per second (frequency) that the high performance counter performs.
/// </summary>
/// <param name="lpFrequency">Frequency the higher performance counter performs.</param>
/// <returns>False if the high performance counter is not supported.</returns>
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceFrequency(out long lpFrequency);
 
I don't know if I can bump threads (I checked for rules but they seem not to exist), but here I go.

Definitely use the "QueryPerformanceCounter()" or "GetTickCount()" functions. These are very accurate, unlike the one built into VB.NET. QueryPerformanceCounter() is a lot more accurate than GetTickCount, but both seem to work fairly well. For a network app, you might want to use QueryPerformanceCounter() just for the accuracy.
 
Back
Top