Skip to content

Resolve concurrency with test stub to resolve #49745. #63299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -799,9 +800,17 @@ private class TestPublisher : IHealthCheckPublisher
public TestPublisher()
{
_started = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
_entries = new ConcurrentQueue<(HealthReport report, CancellationToken cancellationToken)>();
}

public List<(HealthReport report, CancellationToken cancellationToken)> Entries { get; } = new List<(HealthReport report, CancellationToken cancellationToken)>();
private readonly ConcurrentQueue<(HealthReport report, CancellationToken cancellationToken)> _entries;
public IReadOnlyList<(HealthReport report, CancellationToken cancellationToken)> Entries
{
get
{
return _entries.ToList();
}
}

public Exception? Exception { get; set; }

Expand All @@ -811,7 +820,7 @@ public TestPublisher()

public async Task PublishAsync(HealthReport report, CancellationToken cancellationToken)
{
Entries.Add((report, cancellationToken));
_entries.Enqueue((report, cancellationToken));

// Signal that we've started
_started.SetResult(null);
Expand Down
Loading