windows phone 开发常用小技巧 - 退出应用之升级版(三秒内双击退出)

时间:2014-08-09 09:02:37   收藏:0   阅读:274
//设置一个DispatcherTimer,控制三秒内再次点击返回键时执行退出逻辑
 public void ExitBy2Click(System.ComponentModel.CancelEventArgs e)
        {
            if (!IsExit)
            {

                IsExit = true;
                e.Cancel = true;
                _timer = new DispatcherTimer();
                _timer.Start();
                SystemTrayMessage.Instance.StartAdv("再按一次退出", 3, false);
                _timer.Interval = TimeSpan.FromSeconds(3);
                _timer.Tick += (sender, ee) =>
                {
                    IsExit = false;
                    e.Cancel = false;
                    _timer.Stop();
                };

                return;
            }
            else
            {       
                while (NavigationService.BackStack.Any())
                    NavigationService.RemoveBackEntry();
                base.OnBackKeyPress(new CancelEventArgs());
               // App.Current.Terminate();
                //new Microsoft.Xna.Framework.Game().Exit();//wp7
            }

windows phone 开发常用小技巧 - 退出应用之升级版(三秒内双击退出),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!