예제 #1
0
        /// <summary>
        /// Removes a handle from this virtual region. If there are no handles left, this virtual region is removed.
        /// </summary>
        /// <param name="handle">Handle to remove</param>
        public void RemoveHandle(RegionHandle handle)
        {
            bool removedRegions = false;

            lock (_tracking.TrackingLock)
            {
                Handles.Remove(handle);
                UpdateProtection();
                if (Handles.Count == 0)
                {
                    _tracking.RemoveVirtual(this);
                    foreach (var child in _physicalChildren)
                    {
                        removedRegions |= child.RemoveParent(this);
                    }
                }
            }

            if (removedRegions)
            {
                // The first lock will unprotect any regions that have been removed. This second lock will remove them.
                lock (_tracking.TrackingLock)
                {
                    foreach (var child in _physicalChildren)
                    {
                        child.TryDelete();
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Removes a handle from this virtual region. If there are no handles left, this virtual region is removed.
 /// </summary>
 /// <param name="handle">Handle to remove</param>
 public void RemoveHandle(RegionHandle handle)
 {
     lock (_tracking.TrackingLock)
     {
         Handles.Remove(handle);
         UpdateProtection();
         if (Handles.Count == 0)
         {
             _tracking.RemoveVirtual(this);
         }
     }
 }