Skip to content

TestingUtils.WaitUntilAsync(Func<bool, CancellationToken, Task<bool>>, TimeSpan, TimeSpan?, CancellationToken, string?)

WaitUntilAsync(Func<bool, CancellationToken, Task<bool>>, TimeSpan, TimeSpan?, CancellationToken, string?)

static
View source
public static Task WaitUntilAsync(Func<bool, CancellationToken, Task<bool>> predicate, TimeSpan timeout, TimeSpan? delayOnFail = null, CancellationToken cancellationToken = default(CancellationToken), string? predicateExpression = null)
Run the predicate until it succeeds or times out.

Parameters

predicateFunc<bool, CancellationToken, Task<bool>>
The predicate to run. The first argument indicates the final attempt, allowing the predicate to throw a detailed assertion failure. The token is cancelled when the deadline expires or cancellation is requested.
timeoutTimeSpan
The timeout value.
delayOnFailTimeSpan?
The delay before retrying after an unsuccessful attempt.
cancellationTokenCancellationToken
The cancellation token.
predicateExpressionstring?
The expression supplied for predicate.

Returns

A task representing the operation.

Exceptions

System.TimeoutException
The predicate did not succeed before the timeout elapsed.