dotnet / dotNext

Next generation API for .NET
https://dotnet.github.io/dotNext/
MIT License
1.62k stars 121 forks source link

AsyncBarrier does not work #73

Closed ascott18 closed 3 years ago

ascott18 commented 3 years ago

I can't get AsyncBarrier to work at all, even under trivial usage.

The following code never completes - the Console.WriteLine is never reached. Putting breakpoints on the return statements reveals that one of them is reached, but the other never is.

[Fact]
public async Task Test1()
{
    var barrier = new AsyncBarrier(2);

    var results = await Task.WhenAll(
        Task.Run(async () =>
        {
            await barrier.SignalAndWaitAsync();
            return 24;
        }),
        Task.Run(async () =>
        {
            await barrier.SignalAndWaitAsync();
            return 42;
        })
    );

    Console.WriteLine(string.Join(',', results));
}
sakno commented 3 years ago

@ascott18 , thanks for reporting bug. The commit with fix is already in develop branch. Could you please verify the fix? If everything fine I'll publish patched version on NuGet tomorrow.

ascott18 commented 3 years ago

Thanks for the quick turnaround. If the test you added is passing then I'd say its good and fixed.

sakno commented 3 years ago

@ascott18 , release has been published on NuGet.