How to: Detect Changes in Lists of Symbols and Cause an Update of the Call Browser Tool
The views in Call Browser, or any other symbol-browsing tool, must be periodically refreshed to keep the displayed data is current. The refresh mechanism provides invalidating of the old data and repopulating the views with the new data.
The library and each object list in the library maintain their independent counters which are incremented every time the data changes. Editing of source files, recompiling of projects, and adding or removing external components result in an update of the counters. Sometimes a change is significant, such as deletion of a large amount of code in the project. In this case, it is difficult to determine which specific lists are affected and it becomes necessary to invalidate all object lists in the library. To invalidate all object lists, the library counter must be incremented. For small, granular changes, individual lists can be invalidated and updated independently.
The object manager queries the library and the object lists during UI idle cycles to determine the state of each counter in the library. If the counter values have changed from the previous cycle, the object manager invalidates specific object lists or the entire library. The object manager starts querying from the top level object list and moves down the hierarchical tree of lists. Any time a parent list is invalidated, the children lists are also invalidated. The object manager requests the library to provide new data for each invalidated list or for the entire library, and populates the tools views with the new data.
To access the library counter, the object manager calls the UpdateCounter method. To access the individual lists counters, the object manager calls the UpdateCounter method.
Updating the Library Counter
To update the library counter
Implement the UpdateCounter method. The object manager calls this method during UI idle cycle to obtain the current value of the library counter.
' A library counter. Private m_uiUpdateCount As UInteger m_uiUpdateCount = 0 ' Update counter. public void BrowseComponents(System.Collections.ArrayList aComponents) m_CallBrowserILReader.BrowseComponents(aComponents, m_CallGraph) m_uiUpdateCount = m_uiUpdateCount + 1 ' Update counter. public void ResetCallGraph() m_CallGraph.Clear() m_uiUpdateCount = m_uiUpdateCount + 1 ' Obtain the current counter value. public Integer UpdateCounter(UInteger pCurUpdate) pCurUpdate = m_uiUpdateCount Return Microsoft.VisualStudio.VSConstants.S_OK
// A library counter. private uint m_uiUpdateCount; m_uiUpdateCount = 0; // Update counter. public void BrowseComponents(System.Collections.ArrayList aComponents) { m_CallBrowserILReader.BrowseComponents(aComponents, ref m_CallGraph); m_uiUpdateCount++; } // Update counter. public void ResetCallGraph() { m_CallGraph.Clear(); m_uiUpdateCount++; } // Obtain the current counter value. public int UpdateCounter(out uint pCurUpdate) { pCurUpdate = m_uiUpdateCount; return Microsoft.VisualStudio.VSConstants.S_OK; }
See Also
Tasks
How to: Register a Library with the Object Manager
How to: Implement a Library That Supports the Call Browser Tool
How to: Expose Lists of Symbols Provided by the Library to the Object Manager
How to: Identify Symbols in a Library