예제 #1
0
        public override async Task <GeofenceState> RequestState(GeofenceRegion region, CancellationToken cancelToken = default)
        {
            var task = this.gdelegate
                       .WhenStateDetermined()
                       .Where(x => region.Equals(x))
                       .Select(x => x.Status)
                       .Timeout(TimeSpan.FromSeconds(20))
                       .ToTask(cancelToken);

            this.locationManager.RequestState(region.ToNative());
            var result = await task.ConfigureAwait(false);

            return(result);
        }
예제 #2
0
        public override async Task <GeofenceState> RequestState(GeofenceRegion region, CancellationToken cancelToken = default)
        {
            var task = this.gdelegate
                       .WhenStateDetermined()
                       .Where(x => region.Equals(x))
                       .Select(x => x.Status)
                       .Timeout(TimeSpan.FromSeconds(20))
                       .ToTask(cancelToken);

            this.locationManager.RequestState(region.ToNative());
            try
            {
                var result = await task.ConfigureAwait(false);

                return(result);
            }
            catch (TimeoutException ex)
            {
                throw new TimeoutException("Could not retrieve latest GPS coordinates to be able to determine geofence current state", ex);
            }
        }