This commit is contained in:
Chris Cameron
2017-11-15 11:45:00 -05:00
parent 3322b2038f
commit 3ff80a2a39
3 changed files with 6 additions and 10 deletions

View File

@@ -48,9 +48,8 @@ namespace ICD.Common.Utils.Tests
// ReSharper disable once NotAccessedVariable // ReSharper disable once NotAccessedVariable
object handle = ThreadingUtils.SafeInvoke(() => { result = section.TryEnter() ? 0 : 1; }); object handle = ThreadingUtils.SafeInvoke(() => { result = section.TryEnter() ? 0 : 1; });
ThreadingUtils.Sleep(1000);
Assert.IsTrue(ThreadingUtils.Wait(() => result == 1, 1000));
Assert.AreEqual(1, result);
section.Leave(); section.Leave();
@@ -60,9 +59,8 @@ namespace ICD.Common.Utils.Tests
result = section.TryEnter() ? 2 : 0; result = section.TryEnter() ? 2 : 0;
section.Leave(); section.Leave();
}); });
ThreadingUtils.Sleep(1000);
Assert.AreEqual(2, result); Assert.IsTrue(ThreadingUtils.Wait(() => result == 2, 1000));
} }
} }
} }

View File

@@ -44,8 +44,7 @@ namespace ICD.Common.Utils.Tests
}); });
Assert.IsFalse(result); Assert.IsFalse(result);
ThreadingUtils.Sleep(1000); Assert.IsTrue(ThreadingUtils.Wait(() => result, 1000));
Assert.IsTrue(result);
} }
[Test] [Test]
@@ -59,8 +58,7 @@ namespace ICD.Common.Utils.Tests
}, true); }, true);
Assert.IsFalse(result); Assert.IsFalse(result);
ThreadingUtils.Sleep(1000); Assert.IsTrue(ThreadingUtils.Wait(() => result, 1000));
Assert.IsTrue(result);
} }
} }
} }

View File

@@ -17,7 +17,7 @@ namespace ICD.Common.Utils
/// </summary> /// </summary>
/// <param name="condition"></param> /// <param name="condition"></param>
/// <param name="timeout"></param> /// <param name="timeout"></param>
/// <returns></returns> /// <returns>False if the call times out</returns>
public static bool Wait(Func<bool> condition, long timeout) public static bool Wait(Func<bool> condition, long timeout)
{ {
if (condition == null) if (condition == null)