Skip to content

Commit

Permalink
Avoid async void in SKXamlCanvas. (#2720)
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
  • Loading branch information
lindexi authored Jan 31, 2024
1 parent 9274aee commit 08c711c
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 08c711c

Please sign in to comment.