private void Update() { // Release the pedometer pedometer.Dispose(); pedometer = null; for (int i = 0; i < options.Length; i++) { if (i == index) { part.sprite = options[i]; } } }
/// <summary> /// Releases all resources used by the current instance /// </summary> protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _sensor.DataUpdated -= OnSensorDataUpdated; _sensor.Dispose(); } _sensor = null; _disposed = true; } }
public IObservable <int> WhenReadingTaken() => this.observable ??= Observable.Create <int>(ob => { var handler = new EventHandler <PedometerDataUpdatedEventArgs>((sender, args) => ob.OnNext((int)args.StepCount) ); var sensor = new Pedometer { Interval = 1000 }; sensor.DataUpdated += handler; sensor.Start(); return(() => { sensor.Stop(); sensor.DataUpdated -= handler; sensor.Dispose(); }); }) .Publish() .RefCount();
private void OnDisable() { // Release the pedometer pedometer.Dispose(); pedometer = null; }
public void MeterDispose() { _pedometer.Dispose(); }