示例#1
0
        // This can be called to remove a handle from the BoundHandles table.  It should be called only after no more commands are in progress or could be made on the handle.
        internal void Unbind(InstanceHandle handle)
        {
            Fx.Assert(object.ReferenceEquals(this, handle.Owner), "Unbind called on the wrong owner for a handle.");
            Fx.Assert(handle.Id != Guid.Empty, "Unbind called on a handle not even bound to an instance.");

            lock (HandlesLock)
            {
                // The handle may have already been bumped - only remove it if it's still it.
                if (BoundHandles.TryGetValue(handle.Id, out InstanceHandle existingHandle) && object.ReferenceEquals(handle, existingHandle))
                {
                    BoundHandles.Remove(handle.Id);
                }
            }
        }