protected override void DisposeOverride(bool disposeManagedResources) { lock (_SyncRoot) { _IsDisposed = true; } if (disposeManagedResources) { DisposeLogger(); if (_Compass != null) { _Compass.Dispose(); _Compass = null; } if (_GeoWatcher != null) { _GeoWatcher.Dispose(); _GeoWatcher = null; } } }
void CompassCancel() { if (_compass != null) { _compass.Stop(); _compass.Dispose(); _compass = null; } }
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedFrom(e); // Ressourcen freigeben if (compass != null) { compass.Stop(); compass.CurrentValueChanged -= compass_CurrentValueChanged; compass.Dispose(); } }
public void Stop() { if (wtc != null) { wtc.Stop(); wtc.Dispose(); } if (cmp != null) { cmp.Stop(); cmp.Dispose(); } }
public void Dispose() { if (this._compass != null) { _compass.Calibrate -= CompassCalibrate; _compass.CurrentValueChanged -= CompassCurrentValueChanged; _compass.Stop(); _compass.Dispose(); _compass = null; } Dispose(true); GC.SuppressFinalize(this); }
public string ReturnHeading() { if (!Compass.IsSupported) { throw new Exception("Could not load Compass"); } if (_compass == null) { _compass = new Compass(); _compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100); _compass.CurrentValueChanged += new EventHandler <SensorReadingEventArgs <CompassReading> >(_compass_CurrentValueChanged); try { _compass.Start(); } catch (InvalidOperationException e) { if (_compass != null) { _compass.Dispose(); _compass = null; } throw new Exception("Could not initiate compass readings", e); } } string trueHeading = null; if (_compass != null) { // block on the search until the async result return lock (_locker) { while (_trueHeading == null) { Monitor.Pulse(_locker); } trueHeading = _trueHeading; _trueHeading = null; } } return(trueHeading); }
public string ReturnHeading() { if (!Compass.IsSupported) { throw new Exception("Could not load Compass"); } if (_compass == null) { _compass = new Compass(); _compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100); _compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(_compass_CurrentValueChanged); try { _compass.Start(); } catch (InvalidOperationException e) { if (_compass != null) { _compass.Dispose(); _compass = null; } throw new Exception("Could not initiate compass readings", e); } } string trueHeading = null; if (_compass != null) { // block on the search until the async result return lock (_locker) { while (_trueHeading == null) { Monitor.Pulse(_locker); } trueHeading = _trueHeading; _trueHeading = null; } } return trueHeading; }