首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >MFC C++应用程序卡在ProcessShellCommand (CMFCRibbonBar::RecalcLayout)

MFC C++应用程序卡在ProcessShellCommand (CMFCRibbonBar::RecalcLayout)
EN

Stack Overflow用户
提问于 2018-03-19 12:02:28
回答 1查看 707关注 0票数 0

我有一个C++ MFC应用程序(MGen),它显示在Windows10上启动和显示图形用户界面之间的10-20秒暂停。我使用MSVS2017性能分析器(CPU使用)来查找在发布构建过程中占用MSVS2017时间的函数。此暂停位于ProcessShellCommand run中,特别是在CMFCRibbonBar::RecalcLayoutCMFCRibbonBar::LoadFromResourceCDockingManager::EnableAutoHidePanes中。

当某些程序关闭时,暂停似乎被删除或减少。首先,我注意到关闭,固定暂停,并再次启动它,返回暂停。然后我发现,即使没有任务管理器,暂停也可能发生。关闭Chrome有助于将暂停时间减少到2-3秒。

我还发现,如果由MSVS2017中的MFC创建的空项目也存在此问题。

我试过:

  • 重建解决方案-没有帮助
  • 所有版本和调试版本(x86和x64)都存在这个问题。
  • 在MSVS外部运行,在不同的PC上运行(也是Windows 10 )-没有帮助
  • 重新启动Windows似乎暂时解决了这个问题(暂停消失了)。
  • 我在CMainFrame::OnCreate()中注释掉了OnApplicationLook()调用。暂停仍然存在,因为这些函数现在从其他地方调用:Image1 Image2

代码可以在GitHub上找到

代码语言:javascript
运行
复制
    BOOL CMGenApp::InitInstance()
    {
        // InitCommonControlsEx() is required on Windows XP if an application
        // manifest specifies use of ComCtl32.dll version 6 or later to enable
        // visual styles.  Otherwise, any window creation will fail.
        INITCOMMONCONTROLSEX InitCtrls;
        InitCtrls.dwSize = sizeof(InitCtrls);
        // Set this to include all the common control classes you want to use
        // in your application.
        InitCtrls.dwICC = ICC_WIN95_CLASSES;
        InitCommonControlsEx(&InitCtrls);

        CWinAppEx::InitInstance();

        // Initialize OLE libraries
        if (!AfxOleInit())
        {
            AfxMessageBox(IDP_OLE_INIT_FAILED);
            return FALSE;
        }

        AfxEnableControlContainer();

        EnableTaskbarInteraction(FALSE);

        // Initialize GDI+
        Gdiplus::GdiplusStartupInput gdiplusStartupInput;
        Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

        SetRegistryKey(_T("MGen"));
        LoadStdProfileSettings(10);  // Load standard INI file options (including MRU)

        InitContextMenuManager();

        InitKeyboardManager();

        InitTooltipManager();
        CMFCToolTipInfo ttParams;
        ttParams.m_bVislManagerTheme = TRUE;
        theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
            RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

        // Register the application's document templates.  Document templates
        //  serve as the connection between documents, frame windows and views
        CSingleDocTemplate* pDocTemplate;
        pDocTemplate = new CSingleDocTemplate(
            IDR_MAINFRAME,
            RUNTIME_CLASS(CMGenDoc),
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
            RUNTIME_CLASS(CMGenView));
        AddDocTemplate(pDocTemplate);

        // Parse command line for standard shell commands, DDE, file open
        CCommandLineInfo cmdInfo;

        // Enable DDE Execute open
        EnableShellOpen();

        // Dispatch commands specified on the command line.  Will return FALSE if
        // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
        if (!ProcessShellCommand(cmdInfo))
            return FALSE;

        // The one and only window has been initialized, so show and update it
        m_pMainWnd->ShowWindow(SW_SHOW);
        m_pMainWnd->UpdateWindow();
        // call DragAcceptFiles only if there's a suffix
        //  In an SDI app, this should occur after ProcessShellCommand
        // Enable drag/drop open
        m_pMainWnd->DragAcceptFiles();
        return TRUE;
    }

我在两台PC上都使用最新的组件(英特尔I7-8700K有64 Gb RAM,英特尔i7-4770 K有32 Gb RAM,SSD),而且没有性能问题。在应用程序启动暂停期间,应用程序只使用CPU。

详细的性能分析器结果:

更详细的分析:

此外,ExitInstance中也存在同样的问题:

EN

回答 1

Stack Overflow用户

发布于 2018-11-15 18:10:29

这个问题在微软是一个已知的问题。它是用Windows update修复的。因此,要修复Windows 10,需要更新Windows 10。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49362503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档