I don’t know exactly how XNA does this, but when you played with OpenGL a few years ago, I did the same thing using very simple code.
At the heart of this, I assume that XNA has some kind of rendering cycle, it may or may not be integrated with the standard even processing cycle, but, for the sake of example, suppose this is not so. in this case you could write something like this.
TimeSpan FrameInterval = TimeSpan.FromMillis(1000.0/60.0);
DateTime PrevFrameTime = DateTime.MinValue;
while(true)
{
DateTime CurrentFrameTime = DateTime.Now;
TimeSpan diff = DateTime.Now - PrevFrameTime;
if(diff < FrameInterval)
{
DrawScene();
PrevFrameTime = CurrentFrameTime;
}
else
{
Thread.Sleep(FrameInterval - diff);
}
}
, , - Environment.Ticks DateTimes ( ), , . drawScene 60 , , .