Windows runtime Windows应用商店应用程序发布

Windows runtime Windows应用商店应用程序发布,windows-runtime,windows-store-apps,launching,Windows Runtime,Windows Store Apps,Launching,我的Windows应用商店应用程序启动有问题。当我使用“关闭应用程序”手势(从上到下滑动应用程序),然后快速再次启动应用程序时,有时会出现一个空白的黑屏,当我单击它时,会出现“开始”菜单,并记录“MoAppHang”事件 我的应用程序启动活动代码如下: protected override async void OnLaunched(LaunchActivatedEventArgs args) { if (args.PreviousExecutionStat

我的Windows应用商店应用程序启动有问题。当我使用“关闭应用程序”手势(从上到下滑动应用程序),然后快速再次启动应用程序时,有时会出现一个空白的黑屏,当我单击它时,会出现“开始”菜单,并记录“MoAppHang”事件

我的应用程序启动活动代码如下:

       protected override async void OnLaunched(LaunchActivatedEventArgs args)
    {
        if (args.PreviousExecutionState == ApplicationExecutionState.Terminated )
        {
            // Restore the saved session state only when appropriate
            await SuspensionManager.RestoreAsync();                
        }


        // Do not repeat app initialization when already running, just ensure that
        // the window is active
        if (args.PreviousExecutionState == ApplicationExecutionState.Running)
        {
            if (!string.IsNullOrEmpty(args.Arguments))
            {
                Frame f = Window.Current.Content as Frame;
                if (f != null)
                {
                    UseSecondaryTileNavigation(f, args.Arguments);
                }
            }
            Window.Current.Activate();
            return;
        }

        Frame rootFrame;
        if (Window.Current.Content == null)
        {

            // Create a Frame to act as the navigation context and associate it with
            // a SuspensionManager key
            rootFrame = new Frame();
            SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
        }
        else
        {
            rootFrame = (Frame)Window.Current.Content;
        }

        if (!await DatabaseHelper.ExistsDatabase())
        {
            await DatabaseHelper.CreateDatabase();
        }

        if (rootFrame.Content == null)
        {
            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            if (!rootFrame.Navigate(typeof(ItemsPage), "AllGroups"))
            {
                throw new Exception("Failed to create initial page");
            }
        }

        if (!string.IsNullOrEmpty(args.Arguments))
        {
            UseSecondaryTileNavigation(rootFrame, args.Arguments);
        }

        // Place the frame in the current Window and ensure that it is active
        if (Window.Current.Content == null)
        {
            Window.Current.Content = rootFrame;
        }
        Window.Current.Activate();
当用户使用辅助磁贴打开应用程序时,UseSecondaryTileNavigation执行导航(它基本上使用Frame参数,并使用Frame.Navigate将其导航到正确的位置)

我哪里做错了


谢谢大家!

看起来您可能正在启动处理程序中执行一些耗时的工作。我的第一个建议是使用定制的闪屏技术。也就是说,在您的
OnLaunched
处理程序中,尝试设置
Window.Current.Content
并激活该窗口,然后尽快退出该方法。您可以将
Window.Current.Content
设置为只显示加载进度条的页面,并在其中处理实际的加载逻辑

接下来要看的是,当你的应用程序在暂停状态下启动时会发生什么?(你有一个挂起处理程序吗?)当你的应用程序在前一次挂起/关闭完成之前(重新)启动时,它能处理这种情况吗

我注意到,在应用程序完全关闭之前通常需要几秒钟的时间(即使您使用下拉手势关闭它)