This project has moved and is read-only. For the latest updates, please go here.

Another composition notification question

Mar 3, 2009 at 8:56 PM
I am aware of the INotifyImportSatisfaction interface and how to use it, but I have found that it is not quite sufficient to conveniently perform system initialization. What I find myself wanting to know is when all composition is complete, not just when a given object's imports are satisfied. The reason is that if you have two parts, A and B, each of which needs to know about the other, and A is the first instance created (for the sake of this example), then as part of satisfying A's imports, an instance of B is created and its imports are satisfied. When B's ImportCompleted() method is called, A is still somewhere in the process of having its imports satisfied. Basically, the calling order is:


If B relies on something else that A creates and holds (directly or otherwise), it will not be available at the time that B.ImportCompleted() is called. I'd really like another interface similar to the INotifyImportSatisfaction that I can implement as required and whose ImportCompleted() method will be called after all imports for all parts are complete. This would give me a handle to perform some post-composition steps where required while being assured that every part in the system is fully composed.

Has anyone else run into this need? Is there a better way to do this?

Mar 3, 2009 at 9:06 PM
Hi Ron

The easiest way to handle when ALL composition is complete, is to derive from our container and then override GetExportsCore to throw an event such as CompositionComplete. You can then use your derived container as a replacement.