XNA应用程序没有响应 [英] XNA app not responding

查看:135
本文介绍了XNA应用程序没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XNA 3.1应用程序在Windows 7 x64与VS 2008.在〜7秒的窗口将变灰,如果游戏没有焦点(有时!)。标题添加不响应。如果游戏拥有焦点,窗口可能会稍微改变屏幕上的位置,并且我托盘上的应用程序图标会移动,就像打开一个新程序一样。

这只会发生在分秒之间,那么应用程序图标将移回其原始位置。它在调试和释放模式下都这样做。这是奇怪的,因为应用程序不停留在任何循环,只要我能告诉。如果我进入VS并暂停代码,而它没有响应,它显示我的程序类中的Instance.Run像它应该。我已尝试在该时刻暂停;


调用堆栈如下:
[在睡眠,等待或加入]

外部代码。 - >

mscorlib.dll!System.Threading.Thread.Sleep(int millisecondsTimeout)+ 0x5字节
Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Tick ()+ 0x98字节

Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.HostIdle(object sender ...
Microsoft.Xna.Framework.Game.dll !Microsoft.Xna.Framework.GameHost.OnIdle()+ 0x3d字节

...等等。


如果我在暂停时点击运行,程序将工作和解冻,一旦进入这种无响应模式,应用程序将不会解冻自己。当没有响应时,所有的声音继续工作。



此外,我有一个方法覆盖 OnDeactivated()事件,它会在应用程序失去响应时调用,即使应用程序将具有焦点。我已经尝试安装我的显卡的最新驱动程序,但没有解决这个问题。这个问题也会在没有VS的运行可执行文件时发生。就像我说的,这个问题发生〜75%的时间...否则它工作正常。



我发现只有一个论坛帖子关于这个问题:
http://forums.create.msdn.com/forums/p/ 56743 / 346180.aspx



看起来它从未解决。

$结果我在一个Update()方法中检查Mediaplayer.State,并且由于我的分析器,我发现了问题。 MediaPlayer.State是一个昂贵的枚举来检索,一旦我删除该块,它不再挂起。


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.

这篇关于XNA应用程序没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆