示例#1
0
        protected PollingProbe()
        {
            _pollingSleepDurationMS = DefaultPollingSleepDurationMS;
            _pollingTimeoutMinutes  = 5;
            _isPolling = false;
            _pollTimes = new List <DateTime>();

#if __IOS__
            _significantChangePoll = false;
            _significantChangePollOverridesScheduledPolls = false;
            _locationManager = new CLLocationManager();
            _locationManager.LocationsUpdated += async(sender, e) =>
            {
                await Task.Run(async() =>
                {
                    try
                    {
                        CancellationTokenSource canceller = new CancellationTokenSource();

                        // if the callback specified a timeout, request cancellation at the specified time.
                        if (_pollCallback.CallbackTimeout.HasValue)
                        {
                            canceller.CancelAfter(_pollCallback.CallbackTimeout.Value);
                        }

                        await _pollCallback.Action(_pollCallback.Id, canceller.Token, () => { });
                    }
                    catch (Exception ex)
                    {
                        SensusException.Report("Failed significant change poll.", ex);
                    }
                });
            };
#endif
        }
示例#2
0
        protected PollingProbe()
        {
            _pollingSleepDurationMS = DefaultPollingSleepDurationMS;
            _pollingTimeoutMinutes  = 5;
            _isPolling = false;
            _pollTimes = new List <DateTime>();

#if __IOS__
            _significantChangePoll = false;
            _significantChangePollOverridesScheduledPolls = false;
            _locationManager = new CLLocationManager();
            _locationManager.LocationsUpdated += (sender, e) =>
            {
                Task.Run(() =>
                {
                    try
                    {
                        CancellationTokenSource canceller = new CancellationTokenSource();

                        // if the callback specified a timeout, request cancellation at the specified time.
                        if (_pollCallback.CallbackTimeout.HasValue)
                        {
                            canceller.CancelAfter(_pollCallback.CallbackTimeout.Value);
                        }

                        _pollCallback.Action(_pollCallback.Id, canceller.Token, () => { });
                    }
                    catch (Exception ex)
                    {
                        SensusServiceHelper.Get().Logger.Log("Failed significant change poll:  " + ex.Message, LoggingLevel.Normal, GetType());
                    }
                });
            };
#endif
        }