gpt4 book ai didi

c# - Mango 快速应用程序切换和大量处理崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 20:32:02 24 4
gpt4 key购买 nike

我有一个 WP7 应用程序,有时需要进行长时间(5-25 秒)的处理。

对于 Mango,当应用程序设置为休眠状态时正在处理(例如:用户按下 Windows 按钮或锁定屏幕),当用户返回时,应用程序会崩溃。

我在模拟器和我的设备上试过,行为相同。

如果我在 Visual Studio 的 Debug模式下重现它,它不会崩溃,所以很难找到真正发生的事情。

要重现它,启动一个新的 Windows Phone 项目,在 MainPage.xaml 上添加一个按钮,并在执行无限循环的点击事件上添加一个事件处理程序:

while (true)
{
System.Threading.Thread.Sleep(100);
}

我的问题是:到底发生了什么?为什么会崩溃?快速应用切换不应该只是暂停应用进程并恢复它吗?

编辑:我注意到的另一件事是,在运行繁重的进程时,停用和激活的事件似乎不会在我离开/进入应用程序时引发。

最佳答案

在官方 Windows Phone 论坛 ( link ) 上找到了答案。在这里:

为什么会崩溃:

From the time the app is deactivated, it has exactly ten seconds to finish up what it is doing. If the code takes more than ten seconds, the OS will terminate the app.

为什么当我离开/进入应用程序时没有引发停用和激活事件:

If the process is blocking the UI thread this also blocks the message dispatch loop so I suspect that this is the reason why your app never gets a chance to detect and handle the events.

关于c# - Mango 快速应用程序切换和大量处理崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7063261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com