How to get rid of disposed child workitems

Topics: CAB & Smart Client Software Factory
Apr 3, 2006 at 12:01 PM
originally posted by: rdunzl8

I have a (main) workitem with some child workitems that shows in a tabcontrol. When I close a tab, I want to remove the child from the mainworkitem.

I tried


But since "Removing WorkItems is not permitted", I "Use WorkItem.Terminate or WorkItem.Dispose" to clean up the child item, as the argumentexception thrown by the ManagedObjectCollection suggests.

However after calling Dispose on the child workitem it's removed from the mainworkitem's workitems collection, but it's still alive somewhere with a status of "WorkItemStatus.Terminated".

I found out because I didn't remove some eventhandlers when closing/disposing the items which caused some null reference exceptions that riddled me for some hours.

This "being alive somewhere with a status of terminated" behavior of disposed workitems is probably great, but I prefere them to be gone when I call Dispose.

Now, is the terminated status caused by me not cleaning up something properly or what?