Merge pull request #495 from tig/progress

Progress
This commit is contained in:
Charlie Kindel
2020-05-22 09:24:22 -06:00
committed by GitHub

View File

@@ -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);
}
@@ -81,19 +83,21 @@ 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 ()
{
_timer?.Dispose ();
_timer = null;
Application.MainLoop.RemoveTimeout (_timeoutToken);
if (_timeoutToken != null) {
Application.MainLoop.RemoveTimeout (_timeoutToken);
}
_activityProgressBar.Fraction = 1F;
_pulseProgressBar.Fraction = 1F;