Mar 1, 2012 at 6:47 AM
Edited Mar 1, 2012 at 6:59 AM
@yallie: You were faster :)
this behavior feels like a bug, but it´s correct. When the host is disposed, the registered underlying remoting channel is unregistered properly. StopListening is invoked on the server channel, so the channel stops listening for client requests. But
the IPC channel is not killed at this time, even if it doesn´t accept any new client requests. The channel is still in use by a alive object. This object cannot receive and handle new method calls, but it can still send responses. The Notify callback
invocation is such a response.
Abrupt cutting off all wires may lead to an inconsitent system.
Your issue can be solved easily with lifetime control features of Zyan. If I understood everything right, you don´t want to dispose your TrayServer component but notification of clients should be stopped, when the host is disposed. This can be done
inside a cleap-up handler. Such a clean-up handler can be specified on the RegisterComponent method.
() => trayServer,
instance => ((TrayServer)instance).DisconnectNotificationClients()); // <-- Clean-up handler
Code of the TrayServer.DisconnectNotificationClients Method:
public void DisconnectNotificationClients()
if (Notify != null)
Notify = null;
Note that this method isn´t part of the ITrayServer interface and so it is not visible to clients.
There is another thing you must do, that my suggested solution works. Don´t call UnregisterComponent before host.Dispose(). Unregistering a component means removal of the component from the component catalog. Zyan has no control over the component
anymore if you unregister it, and so your clean-up handler is never called.
Another approach is to implement IDisposable in your component. Zyan automaticly calls the Dispose method, when the host is dispose.
If you want to manually start clean-up for a specified component, you should use the CleanUpComponentInstance method of the ComponentCatalog. Remember that component lifetime isn´t controlled by ZyanComponentHost. It´s controlled by ComponentCatalog.
By default, the ComponentCatalog is created by ZyanComponentHost and the DisposeWithHost property is set to true. But there are scenarios where you may want to decouple catalog and host. Imagine a ComponentCatalog instance that is published by many different
host (with different protocols).