feat: Added ThreadingUtils overloads

This commit is contained in:
Chris Cameron
2021-05-24 10:11:49 -04:00
parent 8b848e5127
commit e6dec641f3

View File

@@ -22,7 +22,7 @@ namespace ICD.Common.Utils
private static readonly SafeCriticalSection s_ThreadsSection;
/// <summary>
/// Static contstructor.
/// Static constructor.
/// </summary>
static ThreadingUtils()
{
@@ -30,6 +30,17 @@ namespace ICD.Common.Utils
s_ThreadsSection = new SafeCriticalSection();
}
/// <summary>
/// Wait until the given condition is true.
/// </summary>
/// <param name="condition"></param>
/// <param name="timeout"></param>
/// <returns>False if the call times out</returns>
public static bool Wait(Func<bool> condition, TimeSpan timeout)
{
return Wait(condition, (long)timeout.TotalMilliseconds);
}
/// <summary>
/// Wait until the given condition is true.
/// </summary>
@@ -52,6 +63,15 @@ namespace ICD.Common.Utils
return true;
}
/// <summary>
/// Puts the current thread to sleep for the given amount of time.
/// </summary>
/// <param name="duration"></param>
public static void Sleep(TimeSpan duration)
{
Sleep((int)duration.TotalMilliseconds);
}
/// <summary>
/// Puts the current thread to sleep for the given amount of time.
/// </summary>