public void Run(IGame game) { if (_game != null) throw new InvalidOperationException("A game is already running."); if (_device == null) throw new InvalidOperationException("Setup must be called before Run."); Current = this; Show(); _game = game; try { var sw = Stopwatch.StartNew(); _game.Setup(_device, this); while (_game != null) { Application.DoEvents(); if (!IsDeviceLost()) { var deltaTime = sw.Elapsed; sw.Restart(); if (game.Process(_device, deltaTime)) game.Paint(_device); else { Close(); break; } } } } catch { Close(); throw; } game.ShutDown(_device); Current = null; }