定时器并保存其状态

发布于 2024-12-17 09:03:18 字数 789 浏览 0 评论 0原文

我正在构建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淤浪 2024-12-24 09:03:18

接到电话后,您将收到 框架上的模糊事件

请注意,除了收到的电话之外,还可能会触发此事件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文