Skip to content

Instantly share code, notes, and snippets.

@TinkerWorX
Created August 14, 2012 16:43
Show Gist options
  • Save TinkerWorX/3350754 to your computer and use it in GitHub Desktop.
Save TinkerWorX/3350754 to your computer and use it in GitHub Desktop.
private void RunGame(bool useBlockingRun)
{
try
{
try
{
this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager;
if (this.graphicsDeviceManager != null)
{
this.graphicsDeviceManager.CreateDevice();
}
this.Initialize();
this.inRun = true;
this.BeginRun();
this.gameTime.ElapsedGameTime = TimeSpan.Zero;
this.gameTime.TotalGameTime = this.totalGameTime;
this.gameTime.IsRunningSlowly = false;
this.Update(this.gameTime);
this.doneFirstUpdate = true;
if (!useBlockingRun)
{
if (this.host != null)
{
this.host.StartGameLoop();
}
this.endRunRequired = true;
}
else
{
if (this.host != null)
{
this.host.Run();
}
this.EndRun();
}
}
catch (NoSuitableGraphicsDeviceException noSuitableGraphicsDeviceException1)
{
NoSuitableGraphicsDeviceException noSuitableGraphicsDeviceException = noSuitableGraphicsDeviceException1;
if (!this.ShowMissingRequirementMessage(noSuitableGraphicsDeviceException))
{
throw;
}
}
catch (NoAudioHardwareException noAudioHardwareException1)
{
NoAudioHardwareException noAudioHardwareException = noAudioHardwareException1;
if (!this.ShowMissingRequirementMessage(noAudioHardwareException))
{
throw;
}
}
}
finally
{
if (!this.endRunRequired)
{
this.inRun = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment