diff --git a/ICD.Common.Utils/ThreadingUtils.cs b/ICD.Common.Utils/ThreadingUtils.cs index 55645b7..e0af320 100644 --- a/ICD.Common.Utils/ThreadingUtils.cs +++ b/ICD.Common.Utils/ThreadingUtils.cs @@ -22,7 +22,7 @@ namespace ICD.Common.Utils private static readonly SafeCriticalSection s_ThreadsSection; /// - /// Static contstructor. + /// Static constructor. /// static ThreadingUtils() { @@ -30,6 +30,17 @@ namespace ICD.Common.Utils s_ThreadsSection = new SafeCriticalSection(); } + /// + /// Wait until the given condition is true. + /// + /// + /// + /// False if the call times out + public static bool Wait(Func condition, TimeSpan timeout) + { + return Wait(condition, (long)timeout.TotalMilliseconds); + } + /// /// Wait until the given condition is true. /// @@ -52,6 +63,15 @@ namespace ICD.Common.Utils return true; } + /// + /// Puts the current thread to sleep for the given amount of time. + /// + /// + public static void Sleep(TimeSpan duration) + { + Sleep((int)duration.TotalMilliseconds); + } + /// /// Puts the current thread to sleep for the given amount of time. ///