Exemple #1
0
        private void MainPage_Unloaded(object sender, RoutedEventArgs e)
        {
            // Cleanup.
            if (pir != null)
            {
                pir.MotionDetected -= pir_MotionDetected;
                pir.MotionStopped  -= pir_MotionStopped;
                pir.Dispose();
            }

            if (led != null)
            {
                led.Dispose();
            }
        }
Exemple #2
0
        private void MainPage_Unloaded(object sender, object args)
        {
            // Cleanup
            if (timer != null)
            {
                timer.Tick -= Timer_Tick;
                timer.Stop();
            }

            connection?.Dispose();

            if (deviceClient != null)
            {
                geolocator.PositionChanged -= OnPositionChanged;
                geolocator   = null;
                deviceClient = null;
            }

            led?.Dispose();
            relay?.Dispose();

            if (humitureSensor != null)
            {
                humitureSensor.ReadingChanged -= HumitureSensor_ReadingChanged;
                humitureSensor.Dispose();
            }

            if (motionDetector != null)
            {
                motionDetector.MotionDetected -= MotionDetector_MotionDetected;
                motionDetector.MotionStopped  -= MotionDetector_MotionStopped;
                motionDetector.Dispose();
            }

            if (metalTouchSensor != null)
            {
                metalTouchSensor.TouchDetected -= MetalTouchSensor_TouchRemoved;
                metalTouchSensor.TouchRemoved  -= MetalTouchSensor_TouchDetected;
                metalTouchSensor.Dispose();
            }

            if (flameSensor != null)
            {
                flameSensor.FlameDetected -= FlameSensor_FlameDetected;
                flameSensor.FlameDetected -= FlameSensor_FlameExtinguished;
                flameSensor.Dispose();
            }
        }