Skip to content

Commit 6a5ae88

Browse files
author
Lifeng Lu
committed
Add a unit test to prove the fix is essential.
1 parent 3347544 commit 6a5ae88

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/Microsoft.VisualStudio.Threading.Tests/JoinableTaskCollectionTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,21 @@ public void JoinDisposedTwice()
196196
return Task.CompletedTask;
197197
});
198198
}
199+
200+
[Fact]
201+
public void JoinTillEmptyWorksWithRefCounting()
202+
{
203+
var finishTaskEvent = new AsyncManualResetEvent();
204+
JoinableTask? task = this.JoinableFactory.RunAsync(async delegate { await finishTaskEvent.WaitAsync().ConfigureAwait(false); });
205+
206+
var collection = new JoinableTaskCollection(this.context, refCountAddedJobs: true);
207+
208+
collection.Add(task);
209+
collection.Add(task);
210+
211+
finishTaskEvent.Set();
212+
213+
Task? waiter = collection!.JoinTillEmptyAsync();
214+
Assert.True(waiter.Wait(UnexpectedTimeout));
215+
}
199216
}

0 commit comments

Comments
 (0)