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
object handle = ThreadingUtils.SafeInvoke(() => { result = section.TryEnter() ? 0 : 1; });
ThreadingUtils.Sleep(1000);
Assert.AreEqual(1, result);
Assert.IsTrue(ThreadingUtils.Wait(() => result == 1, 1000));
section.Leave();
@@ -60,9 +59,8 @@ namespace ICD.Common.Utils.Tests
result = section.TryEnter() ? 2 : 0;
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);
ThreadingUtils.Sleep(1000);
Assert.IsTrue(result);
Assert.IsTrue(ThreadingUtils.Wait(() => result, 1000));
}
[Test]
@@ -59,8 +58,7 @@ namespace ICD.Common.Utils.Tests
}, true);
Assert.IsFalse(result);
ThreadingUtils.Sleep(1000);
Assert.IsTrue(result);
Assert.IsTrue(ThreadingUtils.Wait(() => result, 1000));
}
}
}

View File

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