/// <summary> /// Stops reading data from the motion sensor. /// </summary> public void Stop() { if (motion != null) { motion.CurrentValueChanged -= motion_CurrentValueChanged; motion.Stop(); motion = null; IsRunning = false; } }
/// <summary> /// Starts reading data from the motion sensor. /// This method throws an exception if <see cref="Microsoft.Devices.Sensors.Motion.IsSupported"/> /// is false. /// </summary> /// <exception cref="InvalidOperationException">Thrown if motion sensor is not supported</exception> public void Start() { if (!IsRunning) { if (Microsoft.Devices.Sensors.Motion.IsSupported) { motion = new Microsoft.Devices.Sensors.Motion(); motion.CurrentValueChanged += motion_CurrentValueChanged; motion.Start(); IsRunning = true; } else { throw new InvalidOperationException("Motion sensor not supported on this device"); } } }