I have a sessionful WCF service that spawns a process and opens a named pipe to this process when the IsInitiating operation is called. When the IsTerminating operation is called, the service sends a message down the pipe to inform the process on the other end that it can shut-down. Unfortunately, if the client doesn't disconnect gracefully (by calling the IsTerminating operation), then the message is never sent down to the pipe and the other process never exits.
I tried making my service implement IDisposable (in the hope that when the session times out on the server it will call my Dispose method), but this doesn't seem to work.
Is there any way that I can call some code on the server side when the client has disconnected (even if I have to wait for an inactivityTimeout)?