Based on the scenario you described us, implementing IDisposable
on your manager could make the manager instance to be garbage collected if it is not being used and your application needs more resources. Therefore, a possible approach to solve
your problem could be to define the manager as an IModule
and register it in the container as a
. By doing this, the manager instance won't be erased and you may work with the same manager through the entire application lifetime. Notice that if you are using
, you should register the module as follows, since
registers modules as not-Singleton
Registering the host inside the Initialize method of the manager´s IModule
class, will only execute it on the first resolve action, so you can be sure that the registration won't be done twice.
Regarding the deregistration, you could make the manager subscribe to an event, raise that event through
when you want to, and then deregister the host through the manager's module event handler.
If this doesn't help you, it would be useful if you can provide us with more detail of the design of your application or a sample so we can analyze in further detail your scenario.