/// <summary> /// Waits in certain intervals until the method returns true. /// </summary> /// <param name="method">Method to periodically check</param> private void SleepUntilTrue(SleepUntilTrueDelegate method) { for (int i = 0; i < RETRY_COUNT; i++) { if (!method()) { Thread.Sleep(THREAD_SLEEP_INTERVAL); } else { return; } } if (!method()) { throw new Exception("Operation timed out, please try again"); } }
/// <summary> /// Waits in certain intervals until the method returns true. /// </summary> /// <param name="method">Method to periodically check</param> private void SleepUntilTrue(SleepUntilTrueDelegate method) { for (int i = 0; i < RETRY_COUNT; i++) { if (!method()) Thread.Sleep(THREAD_SLEEP_INTERVAL); else return; } if (!method()) throw new Exception("Operation timed out, please try again"); }