优雅地处理后台任务时,应用程序墓碑 [英] Gracefully handle background task when app tombstones

查看:238
本文介绍了优雅地处理后台任务时,应用程序墓碑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是异步CTP和有在后台运行的任务。它的伟大工程,但抛出的时候它的运行异常,并且应用程序被墓碑。唯一的例外是有关数据库上下文为空。

I'm using the async ctp and have a task that runs in the background. It works great but throws an exception when it's running and the app is tombstoned. The exception is related to the database context being null.

该文件说:

当应用程序被墓碑,底层的数据库连接
  被关闭。要立碑后返回到其previous状态下,
  应用程序需要重做它面前有执行任何疑问
  墓碑。

When an application is tombstoned, the underlying database connections are closed. To return to its previous state after tombstoning, an application needs to redo any queries it had performed before it was tombstoned.

我使用的是cancellationtokesource尝试,但似乎并没有工作,因为连接已经关闭。不知道如何处理这样的事情?

I've tried using a cancellationtokesource but this doesn't seem to work as the connection is already closed. Any idea how to handle something like this?

推荐答案

我们也有一些与此问题,但移动应用程序的总体架构往往是面向服务让大多数人不会担心数据库连接。处理墓碑是一般容易出错 - 这个领域是我的项目多产的bug发电机之一。

We also had a number of problems with this, but the general architecture of a mobile app tends to be service oriented so most people will not have to worry about database connections. Handling tombstoning is error prone in general - this area was one of the prolific bug generators in my project.

这是确定(不是很大),为用户的体验,从立碑,而不是最后一个屏幕醒来后返回到开始屏幕。使用IsolatedStorage 并尝试重做 - 否则,你可以缓存你已经拥有的数据屏幕。

It is OK (not great) as a user experience to return to the start screen after waking up from tombstoning and not to the last screen. Otherwise you could cache the data you already have - using the IsolatedStorage and try to redo the screen.

这篇关于优雅地处理后台任务时,应用程序墓碑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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