Пример #1
0
        private void ButtonBackToMenu(object sender, RoutedEventArgs e)
        {
            if (lightSensor != null)
            {
                lightSensor.ReadingChanged -= LightSensorReadingChanged;
            }

            PeriodicTimer.CancelMALTScenario2();

            stackpanel4.Visibility = Visibility.Collapsed;
            stackpanel2.Visibility = Visibility.Visible;
        }
Пример #2
0
        /// <summary>
        /// Unregister from App events and DeviceWatcher events because this page will be unloaded.
        /// </summary>
        protected override void OnNavigatedFrom(NavigationEventArgs eventArgs)
        {
            if (lightSensor != null)
            {
                lightSensor.ReadingChanged -= LightSensorReadingChanged;
            }
            PeriodicTimer.CancelMALTScenario2();

            DisconnectFromDeviceClick(null, null);

            StopDeviceWatchers();
            StopHandlingAppEvents();

            // We no longer care about the device being connected
            EventHandlerForDevice.Current.OnDeviceConnected = null;
            EventHandlerForDevice.Current.OnDeviceClose     = null;

            IsNavigatedAway = true;
            CancelAllIoTasks();
        }