From df7e4f2044700f9007e1b5ca5f8e603b9e521f93 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Sun, 29 Aug 2021 00:46:46 +0200 Subject: [PATCH] If the settings are changed while collecting weather, ignore the exception --- Lora-Map/Model/Sensor/SensorWeather.cs | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Lora-Map/Model/Sensor/SensorWeather.cs b/Lora-Map/Model/Sensor/SensorWeather.cs index 8e27e59..9262692 100644 --- a/Lora-Map/Model/Sensor/SensorWeather.cs +++ b/Lora-Map/Model/Sensor/SensorWeather.cs @@ -25,25 +25,27 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Sensor { private void BackGroundRunner() { while(this.backgroundrunnerAlive) { - List ret = new List(); - foreach(Int32 item in Settings.Instance.Internal.WeatherCellIDs) { - try { - JsonData json = this.webrequests.GetJson("https://maps.dwd.de/geoserver/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&typeName=dwd:Warnungen_Gemeinden&outputFormat=application/json&cql_filter=WARNCELLID=" + item); - if (json.ContainsKey("features") && json["features"].IsArray && json["features"].Count > 0) { - foreach (JsonData warning in json["features"]) { - try { - ret.Add(new Warning(warning)); - } catch { } + try { + List ret = new List(); + foreach(Int32 item in Settings.Instance.Internal.WeatherCellIDs) { + try { + JsonData json = this.webrequests.GetJson("https://maps.dwd.de/geoserver/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&typeName=dwd:Warnungen_Gemeinden&outputFormat=application/json&cql_filter=WARNCELLID=" + item); + if(json.ContainsKey("features") && json["features"].IsArray && json["features"].Count > 0) { + foreach(JsonData warning in json["features"]) { + try { + ret.Add(new Warning(warning)); + } catch { } + } } - } - } catch { } - } - this.Warnungen = ret; - for (Int32 i = 0; i < 1000; i++) { - if (this.backgroundrunnerAlive) { - Thread.Sleep(60); + } catch { } } - } + this.Warnungen = ret; + for(Int32 i = 0; i < 1000; i++) { + if(this.backgroundrunnerAlive) { + Thread.Sleep(60); + } + } + } catch { } } }