From f7e91fb75ed75d523b86f623298382b8a76ea908 Mon Sep 17 00:00:00 2001 From: Alexander Ulitin Date: Thu, 26 Feb 2026 10:17:42 +0100 Subject: [PATCH] API cleanup: IRunWhileScheduler: remove an excessive parameter --- rd-net/Lifetimes/Collections/Viewable/IScheduler.cs | 3 +-- .../Lifetimes/Collections/Viewable/SingleThreadScheduler.cs | 6 ++---- .../Lifetimes/Collections/Viewable/SynchronousScheduler.cs | 4 +--- rd-net/RdFramework/Impl/RdSimpleDispatcher.cs | 4 +--- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/rd-net/Lifetimes/Collections/Viewable/IScheduler.cs b/rd-net/Lifetimes/Collections/Viewable/IScheduler.cs index c70982498..2086215d0 100644 --- a/rd-net/Lifetimes/Collections/Viewable/IScheduler.cs +++ b/rd-net/Lifetimes/Collections/Viewable/IScheduler.cs @@ -32,8 +32,7 @@ public interface IRunWhileScheduler : IScheduler /// /// A delegate to be executed over and over while it returns true. /// Maximum time to spend pumping. Use for no limit. - /// If true, throws when timeout elapses; if false, returns false on timeout. /// True if the condition was reached (condition returned false), false if timeout elapsed (when throwOnTimeout is false). - bool RunWhile(Func condition, TimeSpan timeout, bool throwOnTimeout = false); + bool RunWhile(Func condition, TimeSpan timeout); } } \ No newline at end of file diff --git a/rd-net/Lifetimes/Collections/Viewable/SingleThreadScheduler.cs b/rd-net/Lifetimes/Collections/Viewable/SingleThreadScheduler.cs index b4ce8e595..841897fd7 100644 --- a/rd-net/Lifetimes/Collections/Viewable/SingleThreadScheduler.cs +++ b/rd-net/Lifetimes/Collections/Viewable/SingleThreadScheduler.cs @@ -160,16 +160,14 @@ private void Run() } } - public bool RunWhile(Func condition, TimeSpan timeout, bool throwOnTimeout = false) + public bool RunWhile(Func condition, TimeSpan timeout) { var stopwatch = timeout == TimeSpan.MaxValue ? null : Stopwatch.StartNew(); while (condition()) { if (stopwatch != null && stopwatch.Elapsed >= timeout) - { - if (throwOnTimeout) - throw new TimeoutException($"RunWhile timed out after {timeout}. Elapsed: {stopwatch.Elapsed}."); + { return false; } diff --git a/rd-net/Lifetimes/Collections/Viewable/SynchronousScheduler.cs b/rd-net/Lifetimes/Collections/Viewable/SynchronousScheduler.cs index 0eb6eefbb..d5eb43f09 100644 --- a/rd-net/Lifetimes/Collections/Viewable/SynchronousScheduler.cs +++ b/rd-net/Lifetimes/Collections/Viewable/SynchronousScheduler.cs @@ -42,7 +42,7 @@ private static void Execute(Action action) public bool IsActive => ourActive > 0; public bool OutOfOrderExecution => false; - public bool RunWhile(Func condition, TimeSpan timeout, bool throwOnTimeout = false) + public bool RunWhile(Func condition, TimeSpan timeout) { // SynchronousScheduler executes actions inline when queued, so by the time // RunWhile is called the condition is typically already satisfied. @@ -51,8 +51,6 @@ public bool RunWhile(Func condition, TimeSpan timeout, bool throwOnTimeout { if (stopwatch != null && stopwatch.Elapsed >= timeout) { - if (throwOnTimeout) - throw new TimeoutException($"RunWhile timed out after {timeout}. Elapsed: {stopwatch.Elapsed}."); return false; } } diff --git a/rd-net/RdFramework/Impl/RdSimpleDispatcher.cs b/rd-net/RdFramework/Impl/RdSimpleDispatcher.cs index 4abf0e338..8ffb6bd63 100644 --- a/rd-net/RdFramework/Impl/RdSimpleDispatcher.cs +++ b/rd-net/RdFramework/Impl/RdSimpleDispatcher.cs @@ -84,7 +84,7 @@ public void Queue(Action action) myEvent.Set(); } - public bool RunWhile(Func condition, TimeSpan timeout, bool throwOnTimeout = false) + public bool RunWhile(Func condition, TimeSpan timeout) { var stopwatch = timeout == TimeSpan.MaxValue ? (LocalStopwatch?)null : LocalStopwatch.StartNew(); @@ -92,8 +92,6 @@ public bool RunWhile(Func condition, TimeSpan timeout, bool throwOnTimeout { if (stopwatch.HasValue && stopwatch.Value.Elapsed >= timeout) { - if (throwOnTimeout) - throw new TimeoutException($"RunWhile timed out after {timeout}. Elapsed: {stopwatch.Value.Elapsed}."); return false; }