diff --git a/src/Microcks.Testcontainers/MicrocksContainerExtensions.cs b/src/Microcks.Testcontainers/MicrocksContainerExtensions.cs index 0cff3e1..106ea31 100644 --- a/src/Microcks.Testcontainers/MicrocksContainerExtensions.cs +++ b/src/Microcks.Testcontainers/MicrocksContainerExtensions.cs @@ -100,12 +100,12 @@ private static async Task RefreshTestResultAsync(string httpEndpoint private static async Task WaitForConditionAsync(Func> condition, TimeSpan atMost, TimeSpan delay, TimeSpan interval) { + // Delay before first check + await Task.Delay(delay); + // Cancel after atMost using var cancellationTokenSource = new CancellationTokenSource(atMost); - // Delay before first check - await Task.Delay(delay, cancellationTokenSource.Token); - // Polling while (!await condition()) { @@ -113,7 +113,7 @@ private static async Task WaitForConditionAsync(Func> condition, Time { throw new TaskCanceledException(); } - await Task.Delay(interval, cancellationTokenSource.Token); + await Task.Delay(interval, CancellationToken.None); } }