src/Stratis.Features.FederatedPeg.Tests/CrossChainTestBase.cs
/// <summary>
/// Waits for a function to return true.
/// </summary>
/// <param name="act">The function returning <c>true</c> or <c>false</c>.</param>
/// <param name="failureReason">The failure reason if any.</param>
/// <param name="retryDelayInMiliseconds">How often to retry in milliseconds.</param>
/// <param name="cancellationToken">Cancellation token.</param>
Waits for a function to return true.
Waits for a function to return true .
private static void WaitLoop(Func<bool> act, string failureReason = "Unknown Reason", int retryDelayInMiliseconds = 1000, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken = cancellationToken == default(CancellationToken)
                ? new CancellationTokenSource(Debugger.IsAttached ? 15 * 60 * 1000 : 60 * 1000).Token
                : cancellationToken;
            while (!act())
            {
                try
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    Thread.Sleep(retryDelayInMiliseconds);
                }
                catch (OperationCanceledException e)
                {
                    Assert.False(true, $"{failureReason}{Environment.NewLine}{e.Message}");
                }
            }
        }
private static void WaitLoop ( Func < bool > act , string failureReason = " " , int retryDelayInMiliseconds = 1000 , CancellationToken cancellationToken = default ( CancellationToken ) ) { cancellationToken = cancellationToken == default ( CancellationToken ) ? new CancellationTokenSource ( Debugger . IsAttached ? 15 * 60 * 1000 : 60 * 1000 ) . Token : cancellationToken ; while ( ! act ( ) ) { try { cancellationToken . ThrowIfCancellationRequested ( ) ; Thread . Sleep ( retryDelayInMiliseconds ) ; } catch ( OperationCanceledException e ) { Assert . False ( true , $" { failureReason } { Environment . NewLine } { e . Message } " ) ; } } }
Waits for a function to return true.
Waits for a function to return true .
act
Func<bool>
The function returning truefalse
The function returning truefalse
failureReason
string
The failure reason if any.
The failure reason if any .
retryDelayInMiliseconds
int
None
cancellationToken
CancellationToken
None