From c34b2ce70ef86a29e75942732881e9f4b3819c6d Mon Sep 17 00:00:00 2001 From: deroschr Date: Thu, 9 Jul 2026 09:29:13 +0200 Subject: [PATCH] Aktualisiere Pakete und mache SubStations thread-sicher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die Paketversionen für Tests und Systemabhängigkeiten wurden aktualisiert, um Sicherheits- und Funktionsverbesserungen zu erhalten. In der Klasse CSubStation wurde der Zugriff auf das statische Dictionary SubStations durch ein Lock-Objekt thread-sicher gestaltet, um Race Conditions bei parallelem Zugriff zu vermeiden. --- .gitignore | 1 + JC-AMS/Core.Tests/Core.Tests.csproj | 6 +++--- JC-AMS/Core/Core.csproj | 6 +++--- JC-AMS/Core/Core/System/CSubStation.cs | 29 +++++++++++++++++++------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 0a2aabec1..255fe57ed 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ /Avalonia_Apps/.packages/*.nupkg /.github/upgrades/scenarios/sdk-style-conversion/tasks/01-convert-csv-viewer /CSharpBible/Libraries/Libraries.Package/artifacts/nuget +/JC-AMS/Core/Resource/Version.inc diff --git a/JC-AMS/Core.Tests/Core.Tests.csproj b/JC-AMS/Core.Tests/Core.Tests.csproj index 1f247c1b5..3dfb59df4 100644 --- a/JC-AMS/Core.Tests/Core.Tests.csproj +++ b/JC-AMS/Core.Tests/Core.Tests.csproj @@ -9,15 +9,15 @@ - 18.3.0 + 18.7.0 - 4.1.0 + 4.3.0 all runtime; build; native; contentfiles; analyzers; buildtransitive - 8.0.1 + 10.0.1 diff --git a/JC-AMS/Core/Core.csproj b/JC-AMS/Core/Core.csproj index 8bf0ebf4f..6877ffd77 100644 --- a/JC-AMS/Core/Core.csproj +++ b/JC-AMS/Core/Core.csproj @@ -31,14 +31,14 @@ 4.9.1 - 10.0.5 + 10.0.9 - 10.0.5 + 10.0.9 - 10.0.5 + 10.0.9 4.3.1 diff --git a/JC-AMS/Core/Core/System/CSubStation.cs b/JC-AMS/Core/Core/System/CSubStation.cs index 9eea1eedc..7d6b4a7f1 100644 --- a/JC-AMS/Core/Core/System/CSubStation.cs +++ b/JC-AMS/Core/Core/System/CSubStation.cs @@ -89,6 +89,8 @@ public class CSubStation : CPropNotificationClass, IHasParent , IHasID , IXmlSer /// /// public static Dictionary SubStations = new Dictionary(); + + private static readonly object SubStationsSync = new object(); #endregion #region Interface properties @@ -137,7 +139,11 @@ public CSubStation(CStation cStation, long idSubstation, string sDescription) Station = cStation; this.idSubStation = idSubstation; Description = sDescription; - SubStations[idSubStation] = this; + + lock (SubStationsSync) + { + SubStations[idSubStation] = this; + } } /// @@ -149,10 +155,13 @@ public CSubStation(CStation cStation, long idSubstation, string sDescription) /// private void OnChangeIdSubStation(long oldId, long newId, string name) { - if (oldId > 0) - RemoveSubStation(oldId); - if (newId > 0) - SubStations[newId] = this; + lock (SubStationsSync) + { + if (oldId > 0) + SubStations.Remove(oldId); + if (newId > 0) + SubStations[newId] = this; + } } /// @@ -163,7 +172,10 @@ private void OnChangeIdSubStation(long oldId, long newId, string name) /// private static void RemoveSubStation(long oldId) { - SubStations.Remove(oldId); + lock (SubStationsSync) + { + SubStations.Remove(oldId); + } } #region Interface methods @@ -249,7 +261,10 @@ public void WriteXml(XmlWriter writer) /// public static CSubStation GetSubStationGetStation(long idSubStation) { - return SubStations.ContainsKey(idSubStation) ? SubStations[idSubStation] : null; + lock (SubStationsSync) + { + return SubStations.ContainsKey(idSubStation) ? SubStations[idSubStation] : null; + } } #endregion #endregion