Skip to content

Commit

Permalink
bugfix: close app and task cancelled exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo Lijs committed Mar 17, 2021
1 parent 799d6ca commit 2f17c10
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/MachineLearning.ObjectDetect.WPF/Views/WebcamView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,18 @@ public WebcamView()
ViewModel.CameraOpenCv.ImageGrabbed.Subscribe(async imageGrabbedData =>
{
// Update frame in UI thread
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() =>
try
{
CurrentFPSTextBlock.Text = imageGrabbedData.CurrentFPS.ToString("N1");
WebcamImage.Source = imageGrabbedData.image.ToBitmapSource();
});
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() =>
{
CurrentFPSTextBlock.Text = imageGrabbedData.CurrentFPS.ToString("N1");
WebcamImage.Source = imageGrabbedData.image.ToBitmapSource();
});
}
catch (TaskCanceledException)
{
// App shutting down
}
}).DisposeWith(disposableRegistration);

// Interactions
Expand Down

0 comments on commit 2f17c10

Please sign in to comment.