diff --git a/src/Microsoft.VisualStudio.Threading/JoinableTaskDependencyGraph.cs b/src/Microsoft.VisualStudio.Threading/JoinableTaskDependencyGraph.cs index 5d1cc2e88..324467fd5 100644 --- a/src/Microsoft.VisualStudio.Threading/JoinableTaskDependencyGraph.cs +++ b/src/Microsoft.VisualStudio.Threading/JoinableTaskDependencyGraph.cs @@ -298,7 +298,7 @@ internal struct JoinableTaskDependentData /// When the value in an entry is decremented to 0, the entry is removed from the map. /// [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private WeakKeyDictionary childDependentNodes; + private Dictionary childDependentNodes; /// /// The head of a singly linked list of records to track which task may process events of this task. @@ -309,7 +309,7 @@ internal struct JoinableTaskDependentData /// /// Gets a value indicating whether the is empty. /// - internal bool HasNoChildDependentNode => this.childDependentNodes is null || this.childDependentNodes.Count == 0 || !this.childDependentNodes.Any(); + internal bool HasNoChildDependentNode => this.childDependentNodes is null || this.childDependentNodes.Count == 0; /// /// Gets a snapshot of all joined tasks. @@ -360,7 +360,7 @@ internal static JoinableTaskCollection.JoinRelease AddDependency(IJoinableTaskDe ref JoinableTaskDependentData data = ref parentTaskOrCollection.GetJoinableTaskDependentData(); if (data.childDependentNodes is null) { - data.childDependentNodes = new WeakKeyDictionary(capacity: 2); + data.childDependentNodes = new Dictionary(capacity: 2); } if (data.childDependentNodes.TryGetValue(joinChild, out int refCount) && !parentTaskOrCollection.NeedRefCountChildDependencies) @@ -479,7 +479,7 @@ internal static void AddSelfAndDescendentOrJoinedJobs(IJoinableTaskDependent tas } } - WeakKeyDictionary? childDependentNodes = taskOrCollection.GetJoinableTaskDependentData().childDependentNodes; + Dictionary? childDependentNodes = taskOrCollection.GetJoinableTaskDependentData().childDependentNodes; if (childDependentNodes is object) { foreach (KeyValuePair item in childDependentNodes) @@ -563,7 +563,7 @@ internal static void ComputeSelfAndDescendentOrJoinedJobsAndRemainTasks(IJoinabl return; } - WeakKeyDictionary? dependencies = taskOrCollection.GetJoinableTaskDependentData().childDependentNodes; + Dictionary? dependencies = taskOrCollection.GetJoinableTaskDependentData().childDependentNodes; if (dependencies is object) { foreach (KeyValuePair item in dependencies) @@ -691,7 +691,7 @@ internal void OnTaskCompleted(IJoinableTaskDependent thisDependentNode) if (this.childDependentNodes is object) { - var childrenTasks = new List(this.childDependentNodes.Keys); + Dictionary.KeyCollection? childrenTasks = this.childDependentNodes.Keys; while (existingTaskTracking is object) { RemoveDependingSynchronousTaskFrom(childrenTasks, existingTaskTracking.SynchronousTask, force: existingTaskTracking.SynchronousTask == thisDependentNode); @@ -901,7 +901,7 @@ private static void RemoveDependingSynchronousTask(IJoinableTaskDependent taskOr /// A list of tasks we need update the tracking list. /// The synchronous task we want to remove. /// We always remove it from the tracking list if it is true. Otherwise, we keep tracking the reference count. - private static void RemoveDependingSynchronousTaskFrom(IReadOnlyList tasks, JoinableTask syncTask, bool force) + private static void RemoveDependingSynchronousTaskFrom(IReadOnlyCollection tasks, JoinableTask syncTask, bool force) { Requires.NotNull(tasks, nameof(tasks)); Requires.NotNull(syncTask, nameof(syncTask));