# TestingUtils.WaitUntilSucceededAsync(Func&lt;CancellationToken, Task&lt;bool&gt;&gt;, TimeSpan, TimeSpan?, CancellationToken)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.utils.testingutils/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.utils.testingutils/methods/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/Orleans.TestingHost/Utils/TestingUtils.cs)

```csharp
public static Task<bool> WaitUntilSucceededAsync(Func<CancellationToken, Task<bool>> predicate, TimeSpan timeout, TimeSpan? delayOnFail = null, CancellationToken cancellationToken = default(CancellationToken))
```

Runs the predicate until it succeeds or the monotonic deadline expires.

### Parameters

- `predicate` (`Func<CancellationToken, Task<bool>>`): The predicate to run. The token is cancelled when the deadline expires or cancellation is requested.
- `timeout` (`TimeSpan`): The timeout value.
- `delayOnFail` (`TimeSpan?`): The delay before retrying after an unsuccessful attempt.
- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

`true` if the predicate succeeded before the deadline; otherwise, `false`.
