private void RefreshOwnedObjects(ThreadStack threadStack) { List <WaitObject> newOwnedNodes = new List <WaitObject>(threadStack.OwnedObjects.Values); int indexDelta = r_waitedNodes.Count; int countOld = r_ownedNodes.Count; int countNew = newOwnedNodes.Count; int to = countNew; if (countNew < countOld) { for (int i = countNew; i < countOld; ++i) { r_ownedNodes[countNew].Remove(); r_ownedNodes.RemoveAt(countNew); } } else if (countOld < countNew) { to = countOld; int index = countOld; for (int i = 0; i < (countNew - countOld); ++i) { WaitObject objectAddress = newOwnedNodes[index]; ThreadStackOwnedNode ownedNode = new ThreadStackOwnedNode(r_manager, r_threadStackNode, index + indexDelta, objectAddress); r_ownedNodes.Add(ownedNode); ++index; } } for (int i = 0; i < to; ++i) { r_ownedNodes[i].Refresh(newOwnedNodes[i]); } }
private void RefreshOwnedObjects(ThreadStack threadStack) { List<WaitObject> newOwnedNodes = new List<WaitObject>(threadStack.OwnedObjects.Values); int indexDelta = r_waitedNodes.Count; int countOld = r_ownedNodes.Count; int countNew = newOwnedNodes.Count; int to = countNew; if (countNew < countOld) { for (int i = countNew; i < countOld; ++i) { r_ownedNodes[countNew].Remove(); r_ownedNodes.RemoveAt(countNew); } } else if (countOld < countNew) { to = countOld; int index = countOld; for (int i = 0; i < (countNew - countOld); ++i) { WaitObject objectAddress = newOwnedNodes[index]; ThreadStackOwnedNode ownedNode = new ThreadStackOwnedNode(r_manager, r_threadStackNode, index + indexDelta, objectAddress); r_ownedNodes.Add(ownedNode); ++index; } } for (int i = 0; i < to; ++i) { r_ownedNodes[i].Refresh(newOwnedNodes[i]); } }