async void StartLoop(Application app) { while (!Paused && app != null && app.IsActive) { var elapsed = app.Engine.RunFrame(); var targetMax = 1000000L / FpsLimit; if (elapsed >= targetMax) { await Task.Yield(); } else { await Task.Delay(TimeSpan.FromMilliseconds((targetMax - elapsed) / 1000d)); } if (!UnderlyingPanel.Focused && ForceFocus) { UnderlyingPanel.Focus(); } } }
void UrhoSurface_MouseDown(object sender, MouseEventArgs e) { UnderlyingPanel?.Focus(); }