Exemplo n.º 1
0
        /// <summary>
        /// Performs calculation then fires the <see cref="MeasurementUpdated"/> event.
        /// </summary>
        protected override void Calculate(int rawPressure, int rawTemperature)
        {
            // Perform calculation
            base.Calculate(rawPressure, rawTemperature);

            // Fire event
            MeasurementUpdated?.Invoke(this, Measurement);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs calculation on the device then fires the <see cref="MeasurementUpdated"/> event.
        /// </summary>
        public BarometerMeasurement Update()
        {
            // Thread-safe lock
            lock (_lock)
            {
                // Perform calculation
                _device.Update();
                var measurement = new BarometerMeasurement(_device.Pressure, _device.Temperature);

                // Update property
                Measurement = measurement;

                // Fire event
                MeasurementUpdated?.Invoke(this, measurement);

                // Return result
                return(measurement);
            }
        }