Вы можете использовать System.Timers.Timer, чтобы контролировать, как часто вызывается ваш код рендеринга. В вашем окне, содержащем GLControl-in-WindowsFormsHost, объявите private System.Timers.Timer _timer;
, затем, когда вы будете готовы запустить цикл рендеринга, установите интервал таймера и его обработчик событий, а затем запустите его, как в следующем примере:
private void btnLoadModel_Click(object sender, RoutedEventArgs e)
{
LoadModel(); // do whatever you need to do to prepare your scene for rendering
_timer = new System.Timers.Timer(10.0); // in milliseconds - you might have to play with this value to throttle your framerate depending on how involved your update and render code is
_timer.Elapsed += TimerElapsed;
_timer.Start();
}
private void TimerElapsed(object sender, ElapsedEventArgs e)
{
UpdateModel(); // this is where you'd do whatever you need to do to update your model per frame
// Invalidate will cause the Paint event on your GLControl to fire
_glControl.Invalidate(); // _glControl is obviously a private reference to the GLControl
}
Вам явно нужно добавить using System.Timers
к вашему использованию.