From 488d21b3131e3800a6686cc5bcd5a29b65a9ff36 Mon Sep 17 00:00:00 2001 From: Nathaniel Nunes Date: Sat, 20 Oct 2018 13:26:50 +0530 Subject: [PATCH] Catch FeatureNotSupportedException when navigating back --- Samples/Samples/ViewModel/BarometerViewModel.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Samples/Samples/ViewModel/BarometerViewModel.cs b/Samples/Samples/ViewModel/BarometerViewModel.cs index 2e5982912..f1011364f 100644 --- a/Samples/Samples/ViewModel/BarometerViewModel.cs +++ b/Samples/Samples/ViewModel/BarometerViewModel.cs @@ -83,9 +83,16 @@ void OnBarometerReadingChanged(object sender, BarometerChangedEventArgs e) void OnStop() { - IsActive = false; - Barometer.Stop(); - Barometer.ReadingChanged -= OnBarometerReadingChanged; + try + { + IsActive = false; + Barometer.Stop(); + Barometer.ReadingChanged -= OnBarometerReadingChanged; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"An exception occured: {ex.Message}"); + } } } }