コード例 #1
0
        /// <summary>
        /// Aborts the current active measurement.
        /// </summary>
        /// <exception cref="System.NullReferenceException">Not connected to a device.</exception>
        /// <exception cref="System.Exception">The device is not currently performing measurement</exception>
        public async Task AbortMeasurementAsync()
        {
            if (_comm == null)
            {
                throw new NullReferenceException("Not connected to a device.");
            }
            if (_comm.ActiveMeasurement == null)
            {
                throw new Exception("Device is not measuring.");
            }

            await RunAsync(async() =>
            {
                //Need to check again as the task can be scheduled to run at a later point after which this could have changed
                if (_comm == null)
                {
                    throw new NullReferenceException("Not connected to a device");
                }
                if (_comm.ActiveMeasurement == null)
                {
                    throw new Exception("Device is not measuring.");
                }
                await _comm.AbortAsync();
            });
        }