I have a XNA 3.1 app on Windows 7 x64 with VS 2008. At ~7 seconds the window will go gray if the game does not have focus (sometimes!). The title adds Not Responding. If the game has focus, the window may slightly change position on the screen, and the application icon on my tray moves over as if it is opening a new program.
This only happens for a split second, and then the application icon moves back to its original position. It does this in both debug, and release mode. This is strange because the application is not stuck in any loop as far as I can tell. If I go into VS and pause the code while it is not responding it shows me the Instance.Run in the Program class like it should. I have tried pausing it at that exact moment;
The call stack looks like:
[In a sleep, wait, or join]
External Code. ->
mscorlib.dll!System.Threading.Thread.Sleep(int millisecondsTimeout) + 0x5 bytes
Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Tick() + 0x98 bytes
Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.HostIdle(object sender…
Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.GameHost.OnIdle() + 0x3d bytes
… and so on.
If I hit run while paused, the program will work and unfreeze. The application will not unfreeze itself once it goes into this non-responsive mode. All sounds continue to work when it is not responding.
Additionally, I have a method that overrides the OnDeactivated() event and it gets called when the app loses responsiveness even though the application will HAVE focus. I have tried installing the latest drivers for my graphics card, but that failed to fix this problem. This issue also happens when running the executable without VS. Like I said, this issue happens ~ 75% of the time… otherwise it works fine.
I have found only one forum post regarding this issue:
http://forums.create.msdn.com/forums/p/56743/346180.aspx
It looks like it was never resolved.
Turns out I was checking Mediaplayer.State in an Update() method, and due to my profiler, I found the issue. MediaPlayer.State is an expensive enum to retrieve, and once I removed that block it no longer hangs.