示例#1
0
 private void MainPage_Unloaded(object sender, object args)
 {
     if (humitureSensor != null)
     {
         humitureSensor.ReadingChanged -= HumitureSensor_ReadingChanged;
         humitureSensor.Dispose();
     }
 }
示例#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();
            }
        }
示例#3
0
        private void MainPage_Unloaded(object sender, object args)
        {
            // Cleanup
            if (timer != null)
            {
                timer.Tick -= Timer_Tick;
                timer.Stop();
            }

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

            connection?.Dispose();
        }