From 2d1ab6f12c5fce965a956b50cbd9f93135de88b3 Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 21 Jul 2025 16:53:36 +0100 Subject: [PATCH] Fixes #4196. Application.Begin doesn't refresh the screen at start --- Terminal.Gui/App/Application.Run.cs | 11 +++++++++-- Tests/UnitTests/Views/SpinnerViewTests.cs | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/App/Application.Run.cs b/Terminal.Gui/App/Application.Run.cs index 30c1384a3..48ee9b4d4 100644 --- a/Terminal.Gui/App/Application.Run.cs +++ b/Terminal.Gui/App/Application.Run.cs @@ -212,8 +212,15 @@ public static partial class Application // Run (Begin, Run, End, Stop) NotifyNewRunState?.Invoke (toplevel, new (rs)); - // Force an Idle event so that an Iteration (and Refresh) happen. - Invoke (() => { }); + if (!ConsoleDriver.RunningUnitTests) + { + // Force an Idle event so that an Iteration (and Refresh) happen. + Task.Run (() => + { + Invoke (() => { }); + Task.Delay (10).Wait (); + }); + } return rs; } 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);