Пример #1
0
        /// <summary>
        /// 在将要挂起应用程序执行时调用。    将保存应用程序状态
        /// 将被终止还是恢复的情况下保存应用程序状态,
        /// 并让内存内容保持不变。
        /// </summary>
        /// <param name="sender">挂起的请求的源。</param>
        /// <param name="e">有关挂起的请求的详细信息。</param>
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            Frame root = Window.Current.Content as Frame;

            if (root != null)
            {
#if WINDOWS_PHONE_APP
                if (root.Content is AudioPlay)
                {
                    AudioPlay mp = root.Content as AudioPlay;

                    mp.App_Suspending();
                }
#endif
            }
            var deferral = e.SuspendingOperation.GetDeferral();
            // TODO: 保存应用程序状态并停止任何后台活动
            deferral.Complete();
        }
Пример #2
0
        private void App_Resuming(object sender, object e)
        {
            Frame root = Window.Current.Content as Frame;

            if (root != null)
            {
#if WINDOWS_PHONE_APP
                if (root.Content is AudioMainPage)
                {
                    AudioMainPage mp = root.Content as AudioMainPage;

                    mp.App_Resuming();
                }

                if (root.Content is AudioPlay)
                {
                    AudioPlay mp = root.Content as AudioPlay;

                    mp.App_Resuming();
                }
#endif
            }
        }