我正在构建一个 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();
}
但它不起作用,当电话到达时,它实际上并没有达到这一点。有人有过这样的经历吗?
提前致谢 :)