From e774b7265fe445e3557582d93ad9ece33903ee80 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Thu, 21 May 2020 20:37:32 -0600 Subject: [PATCH 1/2] updated progress demo --- Terminal.Gui/Core.cs | 2 +- UICatalog/Scenarios/Progress.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Core.cs b/Terminal.Gui/Core.cs index 783a33475..12cd26705 100644 --- a/Terminal.Gui/Core.cs +++ b/Terminal.Gui/Core.cs @@ -1650,7 +1650,7 @@ namespace Terminal.Gui { int l = m ? 1 : 0; ny = Math.Max (y, l); if (SuperView == null || SuperView.GetType() != typeof(Toplevel)) - s = Application.Top.HasStatusBar; + s = Application.Top.StatusBar != null; else s = ((Toplevel)SuperView).StatusBar != null; l = s ? Driver.Rows - 1 : Driver.Rows; diff --git a/UICatalog/Scenarios/Progress.cs b/UICatalog/Scenarios/Progress.cs index 1c7c327f9..ac3f27b51 100644 --- a/UICatalog/Scenarios/Progress.cs +++ b/UICatalog/Scenarios/Progress.cs @@ -81,12 +81,12 @@ namespace UICatalog { _activityProgressBar.Fraction = 0F; _pulseProgressBar.Fraction = 0F; - _timer = new Timer ((o) => Application.MainLoop.Invoke (() => Pulse ()), null, 0, 10); + _timer = new Timer ((o) => Application.MainLoop.Invoke (() => Pulse ()), null, 0, 250); // BUGBUG: This timeout does nothing but return true, however it trigger the Application.MainLoop // to run the Action. Without this timeout, the display updates are random, // or triggered by user interaction with the UI. See #155 - _timeoutToken = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (10), loop => true); + //_timeoutToken = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (10), loop => true); } private void Stop () From fe6a2ff585b9e23353356936ff7a744fd364a45c Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Thu, 21 May 2020 20:39:50 -0600 Subject: [PATCH 2/2] disabled AddTimer --- UICatalog/Scenarios/Progress.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/UICatalog/Scenarios/Progress.cs b/UICatalog/Scenarios/Progress.cs index ac3f27b51..641fb8406 100644 --- a/UICatalog/Scenarios/Progress.cs +++ b/UICatalog/Scenarios/Progress.cs @@ -13,7 +13,7 @@ namespace UICatalog { private ProgressBar _activityProgressBar; private ProgressBar _pulseProgressBar; private Timer _timer; - private object _timeoutToken; + private object _timeoutToken = null; public override void Setup () { @@ -59,7 +59,9 @@ namespace UICatalog { { _timer?.Dispose (); _timer = null; - Application.MainLoop.RemoveTimeout (_timeoutToken); + if (_timeoutToken != null) { + Application.MainLoop.RemoveTimeout (_timeoutToken); + } base.Dispose (disposing); } @@ -93,7 +95,9 @@ namespace UICatalog { { _timer?.Dispose (); _timer = null; - Application.MainLoop.RemoveTimeout (_timeoutToken); + if (_timeoutToken != null) { + Application.MainLoop.RemoveTimeout (_timeoutToken); + } _activityProgressBar.Fraction = 1F; _pulseProgressBar.Fraction = 1F;