protected override void OnUpdateFrame(FrameEventArgs e)
{
if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated)
{
this.Close();
return;
}
if (!isDebugging && !isProfiling) // Don't limit frame rate when debugging or profiling.
{
//// Assure we'll at least wait 16 ms until updating again.
//if (this.frameLimiterWatch.IsRunning)
//{
// while (this.frameLimiterWatch.Elapsed.TotalSeconds < 0.016d)
// {
// // Go to sleep if we'd have to wait too long
// if (this.frameLimiterWatch.Elapsed.TotalSeconds < 0.01d)
// System.Threading.Thread.Sleep(1);
// }
//}
// Give the processor a rest if we have the time, don't use 100% CPU even without VSync
if (this.frameLimiterWatch.IsRunning && this.VSync == VSyncMode.Off)
{
while (this.frameLimiterWatch.Elapsed.TotalMilliseconds < Time.MsPFMult)
{
// Enough leftover time? Risk a millisecond sleep.
if (this.frameLimiterWatch.Elapsed.TotalMilliseconds < Time.MsPFMult * 0.75f)
System.Threading.Thread.Sleep(1);
}
}
this.frameLimiterWatch.Restart();
}
DualityApp.Update();
}