From 6ddbfe29b89b0dd68fb344594a0080298e128296 Mon Sep 17 00:00:00 2001 From: bezzad Date: Fri, 20 Sep 2024 11:44:24 +0330 Subject: [PATCH] fixed PauseTokenTest.TestResumeWithoutPause --- src/Downloader.Test/UnitTests/PauseTokenTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Downloader.Test/UnitTests/PauseTokenTest.cs b/src/Downloader.Test/UnitTests/PauseTokenTest.cs index 70bc8da..94fbab3 100644 --- a/src/Downloader.Test/UnitTests/PauseTokenTest.cs +++ b/src/Downloader.Test/UnitTests/PauseTokenTest.cs @@ -7,7 +7,7 @@ namespace Downloader.Test.UnitTests; public class PauseTokenTest { private readonly PauseTokenSource _pauseTokenSource = new(); - private int _actualPauseCount; + private volatile int _actualPauseCount; [Fact] public async Task TestPauseTaskWithPauseToken() @@ -61,7 +61,7 @@ private async Task IncreaseAsync(PauseToken pause, CancellationToken cancel) while (cancel.IsCancellationRequested == false) { await pause.WaitWhilePausedAsync(); - _actualPauseCount++; + Interlocked.Increment(ref _actualPauseCount); await Task.Yield(); } }