Browse Source

Requested change.

José Pedro 8 years ago
parent
commit
af113224c6
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/Avalonia.Controls/ProgressBar.cs

+ 6 - 1
src/Avalonia.Controls/ProgressBar.cs

@@ -112,7 +112,8 @@ namespace Avalonia.Controls
         private void UpdateIsIndeterminate(bool isIndeterminate)
         {
             if (isIndeterminate)
-                _indeterminateAnimation = IndeterminateAnimation.StartAnimation(this);
+                if (_indeterminateAnimation == null || _indeterminateAnimation.Disposed)
+                    _indeterminateAnimation = IndeterminateAnimation.StartAnimation(this);
             else
                 _indeterminateAnimation?.Dispose();
         }
@@ -127,6 +128,9 @@ namespace Avalonia.Controls
             private WeakReference<ProgressBar> _progressBar;
             private IDisposable _indeterminateBindSubscription;
             private TimeSpan _startTime;
+            private bool _disposed;
+
+            public bool Disposed => _disposed;
 
             private IndeterminateAnimation(ProgressBar progressBar)
             {
@@ -171,6 +175,7 @@ namespace Avalonia.Controls
             public void Dispose()
             {
                 _indeterminateBindSubscription?.Dispose();
+                _disposed = true;
             }
         }
     }