Terminate SmartParts

Topics: CAB & Smart Client Software Factory
Aug 16, 2005 at 4:10 AM
originally posted by: hertsin

What is the correct method for disposing/terminating a SmartPart?
Aug 19, 2005 at 4:44 AM
originally posted by: BradWilsonMSFT

A SmartPart is sited into a work item, which controls its lifetime. When the work item is disposed, it will dispose the SmartPart as well.
Aug 19, 2005 at 9:36 AM
originally posted by: hertsin

Ok, I more or less realized that already when I looked through the availible methods for the Workitems and the SmartParts. My next question is then why? Keeping in mind that a Workitem hosts 1..* SmartParts, where a SmartPart can be one part of the use case/process the WorkItem implements. Would it not be a good idea if we were able to dispose a SmartPart but keeping the same workitem alive so the Workitem can create the next SmartPart, rather then disposing both the Workitem and the SmartPart and then we create a new instance of the same workitem (again) with another SmartPart?

Ex:

We have:
- SearchController
- SearchWorkitem
- SearchFormSmartPart
- GridViewSmartPart

…where SearchForm is a form for a database search and GridView displays the result of the search. These two are put in the same workspace.

After the search is complete, we are now forced to dispose the SearchWorkitem if we want to dipsose the SearchFormSmartPart rather then hide it.


Another issue:

Assume we have a ToolStripMenu for both the SearchForm- and the GridViewSmartPart (in the example above) registered with an ElementManager using the same Uri-string or even with different Uri-strings. The Unregistermanager does not appear to work as it is indentedto?


private static IUIElementManager ToolStripManager = null;


ToolStripManager = new UIToolStripManager(mUriToolBar, mToolStrip);
m_WorkItem.GetService<IUIElementService>().RegisterManager(ToolStripManager);



m_WorkItem.GetService<IUIElementService>().UnregisterManager(ToolStripManager.ManagedUri);

m_WorkItem.GetService<IUIElementService>().IsManagerRegistered(ToolStripManager.ManagedUri); <-- returns true!