/// <summary> /// Request sensor data in a non-stop loop. /// ONLY FOR EXECUTION ON AN DEDICATED THREAD. /// </summary> private void RecursiveSensorReading() { while (true) { Values = GetSensorData(); // inform everybody of new sensor data OnSensorDataUpdated(); if (NewSensorValuesAvailable != null) { NewSensorValuesAvailable(this, new EventArgs()); } } }
/// <summary> /// Request sensor data in a non-stop loop. /// ONLY FOR EXECUTION ON AN DEDICATED THREAD. /// </summary> private void EmulateRecursiveSensorReading() { while (true) { Values = EmualateGetSensorData(); // inform everybody of new sensor data OnSensorDataUpdated(); OnBatteryLevelUpdated(); if ((NewSensorValuesAvailable != null) & (NewBatteryLevelAvailable != null)) { NewSensorValuesAvailable(this, new EventArgs()); NewBatteryLevelAvailable(this, new EventArgs()); } Thread.Sleep(500); // pause for a while } }
/// <summary> /// Request sensor data in a non-stop loop. /// ONLY FOR EXECUTION ON AN DEDICATED THREAD. /// </summary> private void RecursiveSensorReading() { while (!_abortPollingRequest) { if (IsConnected & EmulationMode) { Values = EmulateGetSensorData(); } else if (IsConnected & !EmulationMode & _brick != null) { try { Values = GetSensorData(); } catch (Exception) { // do nothing } } } }