Windows Phone 7 (Mango) 应用程序置于后台时断开连接? [英] Windows Phone 7 (Mango) App gets disconnected when put in background?
本文介绍了Windows Phone 7 (Mango) 应用程序置于后台时断开连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户在 Windows Phone 7 Mango 上将应用程序置于后台时,我可以阻止它关闭套接字吗?
Can I prevent my application from having the sockets closed when the user puts it in the background on Windows Phone 7 Mango?
如果是这样,我将如何去做?
If so, how would I go about doing it?
谢谢
推荐答案
不,即使在 Mango 中,您也无法在应用程序未运行时保持持久套接字连接打开.
No, you cannot keep a persistent socket connection open when your application is not running, even in Mango.
您可以:
- 创建一个
PeriodicTask
,每30分钟调用一次,但只能执行10-15秒才被杀死 - 创建一个
ResourceIntensiveTask
,它会在手机接通电源时运行,并且只要你愿意(或直到手机断开电源)都会执行
- Create a
PeriodicTask
that will be called every 30 minutes, but can only execute for 10-15 seconds before being killed - Create a
ResourceIntensiveTask
that will run when the phone is connected to power and will execute for as long as you like (or until the phone is disconnected from power)
这两种类型的任务都可以访问应用程序的隔离存储,但将在单独的应用程序域中执行,因此无法访问变量和其他应用程序状态.
Both types of task have access to your application's isolated storage but will execute in a separate application domain, so it won't have access to variables and other application state.
这篇关于Windows Phone 7 (Mango) 应用程序置于后台时断开连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文