Skip to content

Commit

Permalink
Avoid async void in SKXamlCanvas. (#2720) (#2731)
Browse files Browse the repository at this point in the history
The async void will terminate here. And we can ignore the Dispatcher.RunAsync result and we can receive the exception from TaskScheduler.UnobservedTaskException.

See dotnet/runtime#76367

(cherry picked from commit 08c711c)

Co-authored-by: lindexi <lindexi@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and lindexi authored Jan 31, 2024
1 parent 408ddd1 commit 76ed7a0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ private void OnUnloaded(object sender, RoutedEventArgs e)
display.DpiChanged -= OnDpiChanged;
}

public new async void Invalidate()
public new void Invalidate()
{
if (Dispatcher.HasThreadAccess)
DoInvalidate();
else
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, DoInvalidate);
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, DoInvalidate);
}

partial void DoLoaded();
Expand Down

0 comments on commit 76ed7a0

Please sign in to comment.