KB949753: Problem: MFC Document Interface ON_UPDATE_COMMAND_UI exception handling
- KNOWLEDGE BASE SOLUTIONS
KNOWLEDGE BASE SOLUTIONS PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
Link to Original Article from Microsoft Support
Problem: MFC Document Interface ON_UPDATE_COMMAND_UI exception handling
Action
An MFC document interface application is consuming an unusual amount of CPU during idle operation. When attaching a debugger it shows that there are an extreme number of exceptions being thrown causing the high CPU usage.
Result
•
System operation degrades slight to moderately.
•
If using a debugger to log first chance exceptions, a single type exception will be logged to disk as quickly as it can be written. System operation will be hampered more significantly in this case.
- Edited byAndrew BrennerMSFT, AdministratorTuesday, September 02, 2008 8:43 PMedit
- Edited byXiaoyun Li – MSFT Thursday, September 04, 2008 2:17 AMedit
- Edited byXiaoyun Li – MSFT Tuesday, September 16, 2008 9:57 AMedit
Answers
- Cause
MFC continually pumps the ON_UPDATE_COMMAND_UI message during Idle periods in an MFC documented interface application due to the menu. The CControlBar forwards this message to the handler. If your application is coded to throw exceptions within this event handler then it ends up in a loop of non-stop exceptions.
Resolution
•
If possible alter code not to throw exceptions in this event processing as attached debuggers will be rendered less useful due to an overload.
•
If unable to remove the exception throwing code, add a Sleep() call to give up the remainder of the timeslice. Given that the message only occurs during idle times this will not effect the performance of the application.
DISCLAIMER
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.- Marked As Answer byXiaoyun Li – MSFT Thursday, August 28, 2008 4:42 AM
All Replies
- Cause
MFC continually pumps the ON_UPDATE_COMMAND_UI message during Idle periods in an MFC documented interface application due to the menu. The CControlBar forwards this message to the handler. If your application is coded to throw exceptions within this event handler then it ends up in a loop of non-stop exceptions.
Resolution
•
If possible alter code not to throw exceptions in this event processing as attached debuggers will be rendered less useful due to an overload.
•
If unable to remove the exception throwing code, add a Sleep() call to give up the remainder of the timeslice. Given that the message only occurs during idle times this will not effect the performance of the application.
DISCLAIMER
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.- Marked As Answer byXiaoyun Li – MSFT Thursday, August 28, 2008 4:42 AM


