mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Added ThreadingUtils overloads
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user