Пример #1
0
        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;
                }
            }
        }
Пример #2
0
 void CompassCancel()
 {
     if (_compass != null)
     {
         _compass.Stop();
         _compass.Dispose();
         _compass = null;
     }
 }
Пример #3
0
        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();
            }
        }
Пример #4
0
        public void Stop()
        {
            if (wtc != null)
            {
                wtc.Stop();

                wtc.Dispose();
            }
            if (cmp != null)
            {
                cmp.Stop();
                cmp.Dispose();
            }
        }
Пример #5
0
        public void Dispose()
        {
            if (this._compass != null)
            {
                _compass.Calibrate           -= CompassCalibrate;
                _compass.CurrentValueChanged -= CompassCurrentValueChanged;

                _compass.Stop();
                _compass.Dispose();
                _compass = null;
            }

            Dispose(true);
            GC.SuppressFinalize(this);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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;
        }