Performance Improvement Scenarios
Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista
This topic describes some performance critical scenarios and suggests some tips that can be used to improve the user experience for MMC 3.0 snap-ins. Note that MMC 3.0 must be installed in the GAC to get good startup performance. On Windows Server 2003 SP1 and Windows XP SP2 the user needs to run mmcperf from a user account with administrator privileges to install MMC 3.0 into the GAC. Later versions of the operating systems come with MMC 3.0 pre-installed.
Snap-ins need to update the state or the verbs, as well as the enabled actions in response to a selection change in the results pane. In some cases, this necessitates the removal of all of the current actions and the addition of new actions. Calls must be made to methods that involve the SelectionData object in order to modify individual items that show up in the actions pane. These trigger a redraw of the actions pane which in turn causes flicker in the UI and becomes a major performance issue when the user scrolls through the list.
The methods BeginUpdates and EndUpdates are added to the SelectionData class to support batch updates to the actions pane. A list of all the updates to the actions pane is maintained and the updates are performed as a batch. New content is not rendered between the calls to these methods, which in turn reduces the number of redraws. This scenario applies to MmcListView and to FormView. Below is a code snippet for using a selection change handler in a list view.
protected override void OnSelectionChanged(SyncStatus status)
{
SelectionData.BeginUpdates();
if (this.SelectedNodes.Count == 0)
{
this.SelectionData.Clear();
}
else
{
this.SelectionData.Update(GetSelectedUsers(), this.SelectedNodes.Count > 1, null, null);
this.SelectionData.ActionsPaneItems.Clear();
this.SelectionData.ActionsPaneItems.Add(new Action("Show Selected", "Shows list of selected Users.", -1, "ShowSelected"));
this.SelectionData.EnabledStandardVerbs = StandardVerbs.Delete | StandardVerbs.Refresh | StandardVerbs.Properties;
}
SelectionData.EndUpdates();
}
Snap-ins provide images for nodes and actions pane items. All of the images are stored in the SnapInImageList. Typically, all the images are added in the snap-in constructor and later references are made to this list using indices. An alternative approach is to Add/Remove images as and when they are needed. Although this approach seems practical at first, it does not yield as good a performance as the first one. The entire image list is serialized when it is updated. The assumption is that snap-ins typically do not have a lot of dynamic images and that image list operations are rather infrequent. From a performance viewpoint, the recommended way of handling dynamic images is to add all the images during initialization and to update indices to change the images based on the context.