Esempio n. 1
0
        public override void Switch(IAstTransformer transformer, out Node resultingNode)
        {
            RetryStatement thisNode           = (RetryStatement)this;
            Statement      resultingTypedNode = thisNode;

            transformer.OnRetryStatement(thisNode, ref resultingTypedNode);
            resultingNode = resultingTypedNode;
        }
Esempio n. 2
0
        /// <summary>
        /// Will retry the given statement up to maxRetry times while pausing between each try for
        /// the given interval.
        /// </summary>
        /// <param name="test">Generic boolean statement.</param>
        /// <param name="interval">Amount of time to wait between each retry.</param>
        /// <param name="maxRetry">Maximum number of retries.</param>
        /// <param name="message">Message to print on failure.</param>
        public static void AssertTrueWithTimeout(
            RetryStatement test, TimeSpan interval, int maxRetry, string message)
        {
            for (int tryCount = 0; tryCount <= maxRetry; tryCount++)
            {
                if (test.Invoke())
                {
                    return;
                }

                System.Threading.Thread.Sleep(interval);
            }

            throw new Exception(string.Format("Statement timed out. {0}", message));
        }
Esempio n. 3
0
 public override void OnRetryStatement(RetryStatement node)
 {
     WriteIndented("retry");
     WriteLine();
 }
Esempio n. 4
0
 override public void OnRetryStatement(RetryStatement node)
 {
     WriteIndented();
     WriteKeyword("retry");
     WriteLine();
 }
Esempio n. 5
0
    /// <summary>
    /// Will retry the given statement up to maxRetry times while pausing between each try for
    /// the given interval.
    /// </summary>
    /// <param name="test">Generic boolean statement.</param>
    /// <param name="interval">Amount of time to wait between each retry.</param>
    /// <param name="maxRetry">Maximum number of retries.</param>
    /// <param name="message">Message to print on failure.</param>
    public static void AssertTrueWithTimeout(
        RetryStatement test, TimeSpan interval, int maxRetry, string message)
    {
      for (int tryCount = 0; tryCount <= maxRetry; tryCount++)
      {
        if (test.Invoke())
        {
          return;
        }

        System.Threading.Thread.Sleep(interval);
      }

      throw new Exception(string.Format("Statement timed out. {0}", message));
    }