private void CleanUpIfClosed(uint target_handle, object key)
        {
            if (target_handle < 1)
            {
                throw new ArgumentException("target_handle should be > 0");
            }
            else if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            Contact         contact = Connection.Roster.GetContact(target_handle);
            DispatchManager dm      = contact.DispatchManager;

            Dispatchable d = dm.Get(contact, key, DispatchObject);

            if (d != null)
            {
                if (d.IsClosed)
                {
                    dm.Remove(contact, key, DispatchObject);
                }
                else
                {
                    throw new InvalidOperationException(String.Format("{0} already has dispatchable object type {1} with key {2}",
                                                                      contact.Name, DispatchObject.FullName, key)
                                                        );
                }
            }
        }
        protected virtual void OnClosed(EventArgs args)
        {
            IsClosed = true;

            EventHandler <EventArgs> handler = Closed;

            if (handler != null)
            {
                handler(this, args);
            }

            if (!disposed && key != null && AutoRemoveOnClose && Contact != null)
            {
                DispatchManager dm = contact.DispatchManager;
                dm.Remove(contact, key, this.GetType());
            }
        }