WindowWorkspace and Event Broker

Topics: CAB & Smart Client Software Factory
Aug 13, 2007 at 7:49 PM
I have a single WindowWorkspace that contains several smartparts that are each displayed in their own form. Each smartpart subscribes to events either directly or via a controller object. The problem is that when one of these forms is closed, the necessary teardown steps arent executed, resulting in events being published to controls that have already been disposed, resulting in a runtime exception. I can't post the code, but it seems like a very vanilla situation that can be easilly reproduced.. the only workaround i can come up with is creating a custom workspace, and calling the EventInspector.Unregister method myself, but that cant be the recommended solution.

any help would be most appreciated.
Aug 13, 2007 at 9:28 PM
ok, realized that i need to somehow remove the smartpart from the workitem when the smartpart closes. im just handling the control.disposed event and removing from the workitem and item works fine. is there a more elegant way of doing this?
Aug 14, 2007 at 1:24 PM

Here’s a quote from a thread that might help you:

Whenever we want to sweep an unused view from our resources, we implement the following snippet in the view’s presenter:

public void OnCloseView()

This way we remove the presenter and the view from memory (otherwise the view & presenter would never been swept).

In case that you wanted to do the same with an unused workitem, we should call the Terminate method:


Other related post:

Hope it helps!

Sebastian Iacomuzzi
Aug 14, 2007 at 3:25 PM
excellent, thank you very much!
Aug 14, 2007 at 3:43 PM
the app im building is based on .net 2.0 so i cant leverage the smart client software factory. is there a recommended/automated way to implement these patterns in .net 2,0, or am i on my own as far as implementing cab?