我有一个 Windows Phone 7 应用程序,如何确保它支持快速任务切换? [英] I have a windows phone 7 application how do I make sure it supports fast task switching?

查看:19
本文介绍了我有一个 Windows Phone 7 应用程序,如何确保它支持快速任务切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为开发人员,我需要什么才能确保我的应用支持快速任务切换?

What do I need as a developer to be sure my apps support fast task switching?

理想情况下,我正在寻找类似于开发人员的注意事项清单.

Ideally, I'm looking for like a developer check list of dos and don'ts.

我确实进行了搜索,但我发现的一切都让我觉得我错过了一些东西,更多的是营销而不是开发人员步骤和技术细节.

I did search, but everything I found made me feel like I was missing something, tended to be more marketing instead of developer steps and technical details.

谢谢!

推荐答案

FAS 的大部分工作都会自动为您处理.要记住的主要事情是墓碑对您的应用程序意味着什么.当通过 FAS 恢复时,目的是您不必取消墓碑,因此通常不需要恢复视图模型状态或类似的东西.有几个地方需要您编写代码 - 这是一个快速清单.

Most of the work for FAS is handled for you automatically. The main thing to keep in mind is what Tombstoning means to your application. When resuming via FAS, the intent is that you don't have to un-tombstone anything, so there's usually no need to restore view model state, or anything like that. There are a couple of places for which you will need to write code - here's a quick checklist.

PhoneApplicationPage.OnNavigatingFrom - 对您使用的控件进行试验,以确保 FAS 恢复为您准备的数据.例如 - TextBox 控件可以正确记住您放入其中的所有内容,但 MediaElement 不记得视频或其播放头的位置.

PhoneApplicationPage.OnNavigatingFrom - Experiment with the controls you're using to make sure that FAS restores the data that was there for you. For example - the TextBox control correctly remembers everything you had put into it, but the MediaElement doesn't remember the video or where it's playback head was positioned.

PhoneApplicationPage.OnNavigatedTo - 您在 OnNavigatingFrom 中保存的任何内容都需要在 OnNavigatedTo 中重新应用.例如 - 将视频源重新加载到 MediaElement、重新定位视频并重新启动.

PhoneApplicationPage.OnNavigatedTo - Anything that you saved off in OnNavigatingFrom needs to be re-applied here in OnNavigatedTo. For example - reloading the video source into the MediaElement, repositioning the video and starting it back up again.

Application.Activated - 此事件的事件参数现在包含一个名为 IsApplicationInstancePreserved 的属性.当应用程序通过 FAS 返回时,此属性返回 TRUE,当应用程序从逻辑删除返回时返回 FALSE.所以你会有这样的代码:

Application.Activated - The event args for this event now contain a property called IsApplicationInstancePreserved. This property returns TRUE when the application is coming back through FAS, or FALSE when the application is coming back from Tombstoning. So you'd have code something like this:

private void Application_Activated(object sender, ActivatedEventArgs e)
{
    if (!e.IsApplicationInstancePreserved)
    {
        RestoreStateFromTombstone();
    }
}

private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
    SaveStateForTombstone();
}

这就是必需品.我还没有对 FAS 基础设施进行任何真正的压力测试以查看它在哪里中断,但这对我迄今为止所做的实验很有帮助.

That's the essentials. I haven't done any real stress testing yet on the FAS infrastructure to see where it breaks, but this has served me well for the experimenting I've done so far.

有关详细信息,请参阅 MIX11 会议上的一个名为为快速应用程序切换做好准备的短视频Adina Trufinescu 介绍了有关 FAS 的更多详细信息,这无疑帮助我入门.

For more information, there's a short video from the MIX11 conference called Get Ready for Fast Application Switching presented by Adina Trufinescu that gives more details on FAS which definitely helped me get started.

/克里斯

这篇关于我有一个 Windows Phone 7 应用程序,如何确保它支持快速任务切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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