@@ -71,10 +71,11 @@ internal static JoinableTaskCollection.JoinRelease AddDependency(IJoinableTaskDe
7171 /// </summary>
7272 /// <param name="taskItem">The current joinableTask or collection.</param>
7373 /// <param name="child">The <see cref="IJoinableTaskDependent"/> to join as a child.</param>
74- internal static void RemoveDependency ( IJoinableTaskDependent taskItem , IJoinableTaskDependent child )
74+ /// <param name="forceCleanup">Ignore refCount, it is being used when the child task is completed.</param>
75+ internal static void RemoveDependency ( IJoinableTaskDependent taskItem , IJoinableTaskDependent child , bool forceCleanup = false )
7576 {
7677 Requires . NotNull ( taskItem , nameof ( taskItem ) ) ;
77- JoinableTaskDependentData . RemoveDependency ( taskItem , child ) ;
78+ JoinableTaskDependentData . RemoveDependency ( taskItem , child , forceCleanup ) ;
7879 }
7980
8081 /// <summary>
@@ -400,7 +401,8 @@ internal static JoinableTaskCollection.JoinRelease AddDependency(IJoinableTaskDe
400401 /// </summary>
401402 /// <param name="parentTaskOrCollection">The current joinableTask or collection contains to remove a dependency.</param>
402403 /// <param name="joinChild">The <see cref="IJoinableTaskDependent"/> to join as a child.</param>
403- internal static void RemoveDependency ( IJoinableTaskDependent parentTaskOrCollection , IJoinableTaskDependent joinChild )
404+ /// <param name="forceCleanup">Ignore refCount, it is being used when the child task is completed.</param>
405+ internal static void RemoveDependency ( IJoinableTaskDependent parentTaskOrCollection , IJoinableTaskDependent joinChild , bool forceCleanup )
404406 {
405407 Requires . NotNull ( parentTaskOrCollection , nameof ( parentTaskOrCollection ) ) ;
406408 Requires . NotNull ( joinChild , nameof ( joinChild ) ) ;
@@ -412,7 +414,7 @@ internal static void RemoveDependency(IJoinableTaskDependent parentTaskOrCollect
412414 {
413415 if ( data . childDependentNodes is object && data . childDependentNodes . TryGetValue ( joinChild , out int refCount ) )
414416 {
415- if ( refCount == 1 )
417+ if ( refCount == 1 || forceCleanup )
416418 {
417419 joinChild . OnRemovedFromDependency ( parentTaskOrCollection ) ;
418420
0 commit comments