コード例 #1
0
        public async Task ReloadDataAsync()
        {
            lock (syncRoot)
            {
                if (_isDataReloading)
                {
                    return;
                }
                _isDataReloading = true;
            }

            var savedAlarms = await _repository.GetAllAsync().ConfigureAwait(true);

            GeolocationAlarms.Clear();
            foreach (var geolocationAlarm in savedAlarms)
            {
                GeolocationAlarms.Add(geolocationAlarm);
                if (geolocationAlarm.IsActive && !_geofenceService.IsGeofenceRegistered(geolocationAlarm.Name))
                {
                    _geofenceService.RegisterGeofence(_builder.BuildFromAlarm(geolocationAlarm));
                }
            }

            lock (syncRoot)
                _isDataReloading = false;
        }
コード例 #2
0
        private async Task InsertAsync(Alarm alarm)
        {
            GeolocationAlarms.Add(alarm);
            await _repository.InsertAsync(alarm).ConfigureAwait(false);

            _geofenceService.RegisterGeofence(_builder.BuildFromAlarm(alarm));
        }