public async Task Stop_Monitor() { // TODO: the test runner app (UI version) should do this, until then... if (!HardwareSupport.HasBarometer) { return; } var tcs = new TaskCompletionSource <BarometerData>(); Barometer.ReadingChanged += Barometer_ReadingChanged; void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e) { tcs.TrySetResult(e.Reading); } Barometer.Start(SensorSpeed.UI); var d = await tcs.Task; Barometer.Stop(); Barometer.ReadingChanged -= Barometer_ReadingChanged; Assert.False(Barometer.IsMonitoring); }
public void ToggleBarometer() { try { if (Barometer.IsMonitoring) { Barometer.Stop(); } else { Barometer.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device Console.WriteLine(fnsEx); exception.Text = "Feature not supported on device"; } catch (Exception ex) { // Other error has occurred. Console.WriteLine(ex); exception.Text = "Other error has occurred"; } }
public override async void OnAppearing() { Barometer.ReadingChanged += OnReadingChanged; if (!Barometer.IsMonitoring) { Barometer.Start(SensorSpeed.UI); } var location = await Geolocation.GetLocationAsync(); GPSAltitude = location.Altitude.GetValueOrDefault(); }
private void BarometerBtn_Click(object sender, EventArgs e) { try { if (Barometer.IsMonitoring) { Barometer.Stop(); FindViewById <TextView>(Resource.Id.barometer).Text = "Pressure: off"; } else { Barometer.Start(speed); } } catch (Exception ex) { Toast.MakeText(ApplicationContext, ex.Message, ToastLength.Long).Show(); } }
public Task Start() { try { Barometer.Start(speed); } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device Console.WriteLine(fnsEx.Message); } catch (Exception ex) { // Other error has occurred. Console.WriteLine(ex.Message); } return(Task.CompletedTask); }
public void ToggleBarometer() { try { if (Barometer.IsMonitoring) { Barometer.Stop(); } else { Barometer.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }
private void BarometerCheckButtom_Clicked(object sender, EventArgs e) { try { if (Barometer.IsMonitoring) { Barometer.Stop(); } else { Barometer.Start(SensorSpeed.Default); } } catch (FeatureNotSupportedException fnsEx) { DisplayAlert("Not Supported", "Error: " + fnsEx.Message, "Aceptar"); } catch (Exception ex) { DisplayAlert("Exception", "Error: " + ex.Message, "Aceptar"); } }
public void Barometer_Stop() => Assert.Throws <NotImplementedInReferenceAssemblyException>(() => Barometer.Start(SensorSpeed.Normal));
protected override void OnAppearing() { base.OnAppearing(); Barometer.Start(SensorSpeed.Default); }
public void Start(SensorSpeed speed) { Speed = speed; Barometer.Start(speed); }
void StartButton_Clicked(object sender, EventArgs e) { Barometer.Start((SensorSpeed)speedPicker.SelectedIndex); }
public void Monitor_On_NetStandard() => Assert.Throws <NotImplementedInReferenceAssemblyException>(() => Barometer.Start(SensorSpeed.UI));