From 728d5ae588c16531db285c6e717ce3bdb906baad Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Sat, 21 Jul 2018 11:09:56 +0800 Subject: [PATCH] Check if sender is equal to the argument. Cancel if it doesn't match. --- src/Avalonia.Animation/Animation.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 46b638dcf4..da4b3af38d 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -167,12 +167,18 @@ namespace Avalonia.Animation var tcs = new TaskCompletionSource(); if (this.RepeatCount == RepeatCount.Loop) + { tcs.SetException(new InvalidOperationException("Looping animations must not use the Run method.")); + return tcs.Task; + } - this.Done += delegate + this.Done += (sender, args) => { - tcs.SetResult(null); - } + if (sender == control) + tcs.SetResult(null); + else + tcs.SetCanceled(); + }; this.Apply(control, Observable.Return(true));