コード例 #1
0
        /// <summary>
        /// 等待完成
        /// </summary>
        /// <param name="wait"></param>
        /// <param name="maxWaitTimeMs"></param>
        /// <param name="sleep"></param>
        /// <returns></returns>
        public static bool Wait(IAwait wait, int maxWaitTimeMs, int sleep = 1)
        {
            var time = 0;

            while (!wait.IsDone && time < maxWaitTimeMs)
            {
                Thread.Sleep(sleep);
                time += sleep;
            }

            return(wait.IsDone);
        }
コード例 #2
0
        /// <summary>
        /// Wait for the expectation to become <c>false</c>.
        /// Throw on timeout.
        /// Use the default timeout as specified by configuration in the root object.
        /// </summary>
        /// <param name="awaitObject">The await object.</param>
        /// <param name="expectationText">The expectation text.</param>
        public static void WaitForFalse(this IAwait <bool> awaitObject, string expectationText)
        {
            Predicate <bool> expectation = v => v == false;

            awaitObject.WaitFor(expectation, expectationText);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Bool"/> class.
 /// </summary>
 /// <param name="waiter">The Boolean to wait for.</param>
 /// <param name="snap">Snap the object.</param>
 /// <param name="unsnap">Unsnap the object.</param>
 internal Bool(IAwait <bool> waiter, Func <bool> snap, Action unsnap)
 {
     this.waiter = waiter;
     this.snap   = snap;
     this.unsnap = unsnap;
 }