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;
|
private static readonly SafeCriticalSection s_ThreadsSection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Static contstructor.
|
/// Static constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static ThreadingUtils()
|
static ThreadingUtils()
|
||||||
{
|
{
|
||||||
@@ -30,6 +30,17 @@ namespace ICD.Common.Utils
|
|||||||
s_ThreadsSection = new SafeCriticalSection();
|
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>
|
/// <summary>
|
||||||
/// Wait until the given condition is true.
|
/// Wait until the given condition is true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -52,6 +63,15 @@ namespace ICD.Common.Utils
|
|||||||
return true;
|
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>
|
/// <summary>
|
||||||
/// Puts the current thread to sleep for the given amount of time.
|
/// Puts the current thread to sleep for the given amount of time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user