定时器并保存其状态
我正在构建一个 Windows Phone 应用程序(基本上它是一个游戏,但我没有使用 XNA,Silverlight 就足够了)。图形基于 DispatcherTimer 移动。我想做的基本上是每当电话接到电话时就停止计时器,并在通话结束后重新启动计时器,这样游戏状态就不会丢失。
我尝试使用 :
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
Game.timer.Start();
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
Game.timer.Stop();
}
但它不起作用,当电话到达时,它实际上没有达到这一点。有人有过这样的经历吗?
提前致谢 :)
I am building a windows phone application (basically its a game but I am not using XNA, Silverlight was enough). The graphics are moving based on a DispatcherTimer. What I want to do is basically stop the timer whenever a call arrives on the phone, and start it again after the call has finished, so that the game state is not lost.
I tried with :
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
Game.timer.Start();
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
Game.timer.Stop();
}
but it did not work, it actually does not reach to this point when a call arrives at the phone. Anyone had such experience?
Thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
接到电话后,您将收到 框架上的模糊事件。
请注意,除了收到的电话之外,还可能会触发此事件。
When a call is received you will receieve the Obscured Event on the Frame.
Please note that this event can also be fired for more than just a received phone call though.