From 8464a480e003c38cf136f9a0ceffc5120e039bae Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Sat, 21 Jul 2018 17:49:50 -0500 Subject: [PATCH] Remove callback on animation completion. --- src/Avalonia.Animation/Animation.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 67b937e8ba..98fb652c4a 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -169,12 +169,18 @@ namespace Avalonia.Animation if (this.RepeatCount == RepeatCount.Loop) run.SetException(new InvalidOperationException("Looping animations must not use the Run method.")); - this.Done += (sender, args) => + EventHandler doneCallback = null; + doneCallback = (sender, args) => { if (sender == control) + { run.SetResult(null); + this.Done -= doneCallback; + } }; + this.Done += doneCallback; + this.Apply(control, Observable.Return(true)); return run.Task;