diff --git a/Terminal.Gui/App/ApplicationImpl.cs b/Terminal.Gui/App/ApplicationImpl.cs index 4eadc2ad6..d3b7fed57 100644 --- a/Terminal.Gui/App/ApplicationImpl.cs +++ b/Terminal.Gui/App/ApplicationImpl.cs @@ -275,6 +275,8 @@ public class ApplicationImpl : IApplication if (Application.MainThreadId == Thread.CurrentThread.ManagedThreadId) { action (); + WakeupMainLoop (); + return; } @@ -293,6 +295,15 @@ public class ApplicationImpl : IApplication return false; } ); + + WakeupMainLoop (); + + void WakeupMainLoop () + { + // Ensure the action is executed in the main loop + // Wakeup mainloop if it's waiting for events + Application.MainLoop?.Wakeup (); + } } /// diff --git a/Terminal.Gui/ViewBase/View.Drawing.cs b/Terminal.Gui/ViewBase/View.Drawing.cs index 912133e78..a8d2d4bf8 100644 --- a/Terminal.Gui/ViewBase/View.Drawing.cs +++ b/Terminal.Gui/ViewBase/View.Drawing.cs @@ -807,7 +807,7 @@ public partial class View // Drawing APIs } // There was multiple enumeration error here, so calling ToArray - probably a stop gap - foreach (View subview in SubViews.ToArray ()) + foreach (View subview in InternalSubViews) { if (subview.Frame.IntersectsWith (viewPortRelativeRegion)) { diff --git a/Tests/UnitTests/Views/SpinnerViewTests.cs b/Tests/UnitTests/Views/SpinnerViewTests.cs index 6382f8297..a77fa9488 100644 --- a/Tests/UnitTests/Views/SpinnerViewTests.cs +++ b/Tests/UnitTests/Views/SpinnerViewTests.cs @@ -11,6 +11,8 @@ public class SpinnerViewTests (ITestOutputHelper output) [InlineData (false)] public void TestSpinnerView_AutoSpin (bool callStop) { + ConsoleDriver.RunningUnitTests = true; + SpinnerView view = GetSpinnerView (); Assert.Empty (Application.MainLoop.TimedEvents.Timeouts);