我可以在应用关闭时让计时器运行(在后台) [英] can I still let a timer run when the app closes (in background)

查看:198
本文介绍了我可以在应用关闭时让计时器运行(在后台)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在构建一个应用程序(Windows Phone 7.5 en  8),用于管理足球游戏。


用户必须能够注册目标等。所以我正在使用dispatchTimer。


我已经能够让计时器在空闲模式下运行(phoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled)。


但是,如果用户必须拨打发送whatsapp消息的电话呢?


如何让用户"靠近"申请,而不会丢失计时器?


Thanx帮助。



解决方案


当用户离开你的应用程序时,你需要做墓碑以保留页面状态。 />
以下是使用Example进行逻辑删除的详细说明。

http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff967548%28v=vs.105 %29.aspx



一旦您的用户要离开呼叫页面或WhatsApp消息,您需要检查定时器是否正在运行。如果计时器正在运行然后你只是得到那个时间并保存在隔离存储中然后当用户回到你的应用程序然后你需要检查
上次是否有任何运行计时器然后你从那个时间继续计时器其他开始新。 :)


Hello,

i'm building an app (Windows Phone 7.5 en 8)  for administrating a soccer game.

User must be able to register goals etc. So i'm using an dispatchTimer.

I'm already able to let the timer run in Idle mode (phoneApplicationService.Current.ApplicationIdleDetectionMode= IdleDetectionMode.Disabled ).

But what if user has to make an Phone call of sent an whatsapp message?

How do I let user "close" the application, without losing the Timer?

Thanx for helping.

解决方案

Hi,

You Need To Do Tombstoning To Preserve Page States When User Is Leaving Your App.
Here is detailed description of tombstoning with Example.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff967548%28v=vs.105%29.aspx

Once Your User is going to leave the page for call or WhatsApp Message Then You Need To Check Is Timer is Running. If Timer is Running Then You Just Get That Time And Save In Isolated Storage and Then When User Comes Back to Your App And Then You Need To Check Is There Any Running Timer Last Time Then You Continue Timer From That Time Else Start New. :)


这篇关于我可以在应用关闭时让计时器运行(在后台)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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