// Must be called with HandlesLock held.
        void CancelReference(ref InstanceHandleReference reference, ref List <InstanceHandleReference> handlesPendingResolution)
        {
            Guid wasBoundToInstanceId = reference.InstanceHandle.Id;

            try
            {
                LockResolutionMarker marker = reference as LockResolutionMarker;
                if (marker != null && !marker.IsComplete)
                {
                    if (handlesPendingResolution == null)
                    {
                        handlesPendingResolution = new List <InstanceHandleReference>(1);
                    }
                    handlesPendingResolution.Add(marker);
                }
            }
            finally
            {
                reference.Cancel();
                reference = null;
            }

            ProcessInProgressHandles(ref handlesPendingResolution);

            if (wasBoundToInstanceId != Guid.Empty)
            {
                Queue <InstanceHandleReference> instanceQueue;
                if (InProgressHandlesPerInstance.TryGetValue(wasBoundToInstanceId, out instanceQueue))
                {
                    while (instanceQueue.Count > 0)
                    {
                        InstanceHandleReference handleRef = instanceQueue.Peek();
                        if (handleRef.InstanceHandle != null)
                        {
                            if (CheckOldestReference(handleRef, ref handlesPendingResolution))
                            {
                                break;
                            }
                        }
                        instanceQueue.Dequeue();
                    }

                    if (instanceQueue.Count == 0)
                    {
                        InProgressHandlesPerInstance.Remove(wasBoundToInstanceId);
                    }
                }
            }
        }
        private void CancelReference(ref InstanceHandleReference reference, ref List <InstanceHandleReference> handlesPendingResolution)
        {
            Queue <InstanceHandleReference> queue;
            Guid id = reference.InstanceHandle.Id;

            try
            {
                LockResolutionMarker item = reference as LockResolutionMarker;
                if ((item != null) && !item.IsComplete)
                {
                    if (handlesPendingResolution == null)
                    {
                        handlesPendingResolution = new List <InstanceHandleReference>(1);
                    }
                    handlesPendingResolution.Add(item);
                }
            }
            finally
            {
                reference.Cancel();
                reference = null;
            }
            this.ProcessInProgressHandles(ref handlesPendingResolution);
            if ((id != Guid.Empty) && this.InProgressHandlesPerInstance.TryGetValue(id, out queue))
            {
                while (queue.Count > 0)
                {
                    InstanceHandleReference handleRef = queue.Peek();
                    if ((handleRef.InstanceHandle != null) && this.CheckOldestReference(handleRef, ref handlesPendingResolution))
                    {
                        break;
                    }
                    queue.Dequeue();
                }
                if (queue.Count == 0)
                {
                    this.InProgressHandlesPerInstance.Remove(id);
                }
            }
        }
 private void CancelReference(ref InstanceHandleReference reference, ref List<InstanceHandleReference> handlesPendingResolution)
 {
     Queue<InstanceHandleReference> queue;
     Guid id = reference.InstanceHandle.Id;
     try
     {
         LockResolutionMarker item = reference as LockResolutionMarker;
         if ((item != null) && !item.IsComplete)
         {
             if (handlesPendingResolution == null)
             {
                 handlesPendingResolution = new List<InstanceHandleReference>(1);
             }
             handlesPendingResolution.Add(item);
         }
     }
     finally
     {
         reference.Cancel();
         reference = null;
     }
     this.ProcessInProgressHandles(ref handlesPendingResolution);
     if ((id != Guid.Empty) && this.InProgressHandlesPerInstance.TryGetValue(id, out queue))
     {
         while (queue.Count > 0)
         {
             InstanceHandleReference handleRef = queue.Peek();
             if ((handleRef.InstanceHandle != null) && this.CheckOldestReference(handleRef, ref handlesPendingResolution))
             {
                 break;
             }
             queue.Dequeue();
         }
         if (queue.Count == 0)
         {
             this.InProgressHandlesPerInstance.Remove(id);
         }
     }
 }
Ejemplo n.º 4
0
        // Must be called with HandlesLock held.
        void CancelReference(ref InstanceHandleReference reference, ref List<InstanceHandleReference> handlesPendingResolution)
        {
            Guid wasBoundToInstanceId = reference.InstanceHandle.Id;

            try
            {
                LockResolutionMarker marker = reference as LockResolutionMarker;
                if (marker != null && !marker.IsComplete)
                {
                    if (handlesPendingResolution == null)
                    {
                        handlesPendingResolution = new List<InstanceHandleReference>(1);
                    }
                    handlesPendingResolution.Add(marker);
                }
            }
            finally
            {
                reference.Cancel();
                reference = null;
            }

            ProcessInProgressHandles(ref handlesPendingResolution);

            if (wasBoundToInstanceId != Guid.Empty)
            {
                Queue<InstanceHandleReference> instanceQueue;
                if (InProgressHandlesPerInstance.TryGetValue(wasBoundToInstanceId, out instanceQueue))
                {
                    while (instanceQueue.Count > 0)
                    {
                        InstanceHandleReference handleRef = instanceQueue.Peek();
                        if (handleRef.InstanceHandle != null)
                        {
                            if (CheckOldestReference(handleRef, ref handlesPendingResolution))
                            {
                                break;
                            }
                        }
                        instanceQueue.Dequeue();
                    }

                    if (instanceQueue.Count == 0)
                    {
                        InProgressHandlesPerInstance.Remove(wasBoundToInstanceId);
                    }
                }
            }
        }