private void RemoveExpiredInstanceContexts()
        {
            try
            {
                while (true)
                {
                    lock (SyncRoot)
                    {
                        List <SharedInstanceContextInfo> toRemove = new List <SharedInstanceContextInfo>();

                        foreach (var key in this.instanceContexts.Keys)
                        {
                            InstanceContext           context = this.instanceContexts[key];
                            SharedInstanceContextInfo info    = context.Extensions.Find <SharedInstanceContextInfo>();
                            toRemove.Add(info);
                        }

                        foreach (var info in toRemove)
                        {
                            if (info.IsExpired())
                            {
                                info.DecrementBusyCount(); // let it get to 0
                            }
                        }
                    }

                    Thread.CurrentThread.Join(1000); // check again in 1 second
                }
            }
            catch (ThreadAbortException) { }
        }
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            InstanceContext           instanceContext = (InstanceContext)correlationState;
            SharedInstanceContextInfo info            = instanceContext.Extensions.Find <SharedInstanceContextInfo>();

            info.DecrementBusyCount();
        }