Skip to content

Commit 3e85f7e

Browse files
author
Lifeng Lu
committed
Add some comments to the unit test.
1 parent 3c71d1e commit 3e85f7e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,6 +4179,7 @@ private async Task<JoinableTask> SpinOffMainThreadTaskForJoinableTaskDependencie
41794179

41804180
using (this.context.SuppressRelevance())
41814181
{
4182+
// this task creates a circular loop.
41824183
task2 = joinableTaskFactory.RunAsync(async () =>
41834184
{
41844185
joinableTaskCollection.Join();
@@ -4221,12 +4222,18 @@ private async Task<JoinableTask> SpinOffMainThreadTaskForJoinableTaskDependencie
42214222

42224223
await this.context.Factory.SwitchToMainThreadAsync();
42234224

4225+
// Due to circular reference, this add/remove reference to lead incompleted state
4226+
// the joinableTaskCollection will retain refcount to the JTF.Run task.
42244227
using (joinableTaskCollection.Join())
42254228
{
42264229
}
42274230

42284231
using (mainThreadJoinedCollection.Join())
42294232
{
4233+
// This IsMainThreadBlocked triggers the incompleted state to be cleaned up.
4234+
// JTF.Run joins the completed task through the middle collection to expose the
4235+
// inconsistent between two logic, so the recomputation won't clean up the circular
4236+
// dependency loop correctly.
42304237
await this.context.Factory.RunAsync(() =>
42314238
{
42324239
return Task.FromResult(this.context.IsMainThreadBlocked());

0 commit comments

Comments
 (0)