mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-08-31 19:28:18 +00:00
feat: Added ThreadingUtils overloads
This commit is contained in:
parent
8b848e5127
commit
e6dec641f3
1 changed files with 21 additions and 1 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue