Skip to main content
deleted 127 characters in body; edited title
Source Link
user1430
user1430

Game.Exit prevents from launching again Why does my game exit immediately if I restart it after calling Exit()?

When launching a game multiple times in a console, the first time this.Exit()this.Exit() on the game class is called, all following games do not properly run. Instead they existexit immediately.

For example, if I have a function that does:

foreach(var i in options) {
  using(var game = new MyGame()) {
    game.Run();
  }
}

and the game class has

protected override void Update(GameTime gameTime)
{
  if(gameTime.TotalGameTime.TotalSeconds > 3)
    this.Exit();
  base.Update(gameTime);
}

then the first instance will execute just fine (for 3 seconds), but the second will exit immediately.

How can I prevent XNA from making the second games die immediately.

P.S. This has nothing to do with the gameTime variable, I've checked that in the second situation the this.Exit is never even called.?

Game.Exit prevents from launching again

When launching a game multiple times in a console, the first time this.Exit() on the game class is called, all following games do not properly run. Instead they exist immediately.

For example, if I have a function that does:

foreach(var i in options) {
  using(var game = new MyGame()) {
    game.Run();
  }
}

and the game class has

protected override void Update(GameTime gameTime)
{
  if(gameTime.TotalGameTime.TotalSeconds > 3) this.Exit();
  base.Update(gameTime);
}

then the first instance will execute just fine (for 3 seconds), but the second will exit immediately.

How can I prevent XNA from making the second games die immediately.

P.S. This has nothing to do with the gameTime variable, I've checked that in the second situation the this.Exit is never even called.

Why does my game exit immediately if I restart it after calling Exit()?

When launching a game multiple times in a console, the first time this.Exit() on the game class is called, all following games do not properly run. Instead they exit immediately.

For example, if I have a function that does:

foreach(var i in options) {
  using(var game = new MyGame()) {
    game.Run();
  }
}

and the game class has

protected override void Update(GameTime gameTime)
{
  if(gameTime.TotalGameTime.TotalSeconds > 3)
    this.Exit();
  base.Update(gameTime);
}

then the first instance will execute just fine (for 3 seconds), but the second will exit immediately.

How can I prevent XNA from making the second games die immediately?

Source Link

Game.Exit prevents from launching again

When launching a game multiple times in a console, the first time this.Exit() on the game class is called, all following games do not properly run. Instead they exist immediately.

For example, if I have a function that does:

foreach(var i in options) {
  using(var game = new MyGame()) {
    game.Run();
  }
}

and the game class has

protected override void Update(GameTime gameTime)
{
  if(gameTime.TotalGameTime.TotalSeconds > 3) this.Exit();
  base.Update(gameTime);
}

then the first instance will execute just fine (for 3 seconds), but the second will exit immediately.

How can I prevent XNA from making the second games die immediately.

P.S. This has nothing to do with the gameTime variable, I've checked that in the second situation the this.Exit is never even called.