定时器并保存其状态

时间:2011-11-22 16:36:16

标签: windows-phone-7 state dispatchertimer

我正在构建一个Windows手机应用程序(基本上它是一个游戏,但我没有使用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();
    }

但它没有用,当电话到达手机时,它实际上没有达到这一点。有人有这样的经历吗?

提前致谢:)

0 个答案:

没有答案