public async Task SelectWithinBoundsAsync() { try { double minLat = 0.0; double minLon = 0.0; double maxLat = 0.0; double maxLon = 0.0; object o = executeScript("getBounds", null); if (o != null && o.GetType() != typeof(DBNull)) { string s = o.ToString().Replace("(", "").Replace(")", ""); string[] parts = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); minLat = Utils.Conversion.StringToDouble(parts[0]); minLon = Utils.Conversion.StringToDouble(parts[1]); maxLat = Utils.Conversion.StringToDouble(parts[2]); maxLon = Utils.Conversion.StringToDouble(parts[3]); } using (Utils.DataUpdater upd = new Utils.DataUpdater(Core.ApplicationData.Instance.ActiveDatabase)) { await Task.Run(new Action(() => { try { //first get a list of geocache codes List <string> gcList = OKAPIService.GetGeocachesInBBox(SiteManager.Instance.ActiveSite, minLat, minLon, maxLat, maxLon); using (Utils.ProgressBlock progress = new Utils.ProgressBlock("ImportGeocaches", "ImportGeocaches", gcList.Count, 0, true)) { int gcupdatecount = 1; int max = gcList.Count; while (gcList.Count > 0) { List <string> lcs = gcList.Take(gcupdatecount).ToList(); gcList.RemoveRange(0, lcs.Count); List <OKAPIService.Geocache> caches = OKAPIService.GetGeocaches(SiteManager.Instance.ActiveSite, lcs); Import.AddGeocaches(Core.ApplicationData.Instance.ActiveDatabase, caches); if (!progress.Update("ImportGeocaches", max, max - gcList.Count)) { break; } } } } catch (Exception e) { Core.ApplicationData.Instance.Logger.AddLog(this, e); } })); } } catch (Exception e) { Core.ApplicationData.Instance.Logger.AddLog(this, e); } }