Skip to content

Commit e5cb937

Browse files
authored
Merge pull request #3816 from Sergio0694/bugfix/storyboard-event-unsubscribe
Added removal for Storyboard completion handler
2 parents bf80275 + 168ea39 commit e5cb937

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Microsoft.Toolkit.Uwp.UI.Animations/Extensions/StoryboardAnimations.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ public static Task BeginAsync(this Storyboard storyboard)
2323
{
2424
TaskCompletionSource<object?> taskCompletionSource = new TaskCompletionSource<object?>();
2525

26-
storyboard.Completed += (_, _) => taskCompletionSource.SetResult(null);
26+
void OnCompleted(object sender, object e)
27+
{
28+
((Storyboard)sender).Completed -= OnCompleted;
29+
30+
taskCompletionSource.SetResult(null);
31+
}
32+
33+
storyboard.Completed += OnCompleted;
2734

2835
storyboard.Begin();
2936

0 commit comments

Comments
 (0)