I have simple blank project other than adding a song to play in the background.
I load the song file at LoadContent, and play it at BeginRun. In my EndRun, I have MediaPlayer.Stop() being called, however, sometimes upon exiting (by pressing Esc), the game does not immediately close (the audio continues to play, and the process continues to exist). It will continue playing for some time until it finally exits on its own.
What is causing the game to continue running even after Exit() has been called?
using Microsoft.Xna.Framework;
namespace Game1
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Update(GameTime gameTime)
{
Exit();
}
}
}
When you run it, it will immediately exit, but you will still see the process running in the background in the task manager indefinitely (run without debugging).
I thought I was alone. I’m currently experiencing this issue but never bothered to report it since I’ve made some serious modifications to the framework in order to start a server a window and graphic adapter. So I blamed myself.