/// <summary> /// Blocks the calling thread until the callback returns true. Callback will be called when given maxWaitTime milliseconds expire or immediately when Unblock() is called by another thread. /// </summary> /// <param name="callback">Method to call when we're checking whether to return control to the caller. Should return true to cause this method to exit, false for it to continue looping.</param> /// <param name="maxWaitTime"></param> public void BlockingLoop(Toolkit.BoolCallback callback, int maxWaitTime) { lock (_lock) { while (!callback()) { Monitor.Wait(_lock, maxWaitTime); } } }
/// <summary> /// Blocks the calling thread until the callback returns true. Callback will be called when MaxWaitTime milliseconds expire or immediately when Unblock() is called by another thread. /// </summary> /// <param name="callback">Method to call when we're checking whether to return control to the caller. Should return true to cause this method to exit, false for it to continue looping.</param> public void BlockingLoop(Toolkit.BoolCallback callback) { BlockingLoop(callback, _maxWaitTime); }