Skip to content
Merged

sync #771

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions JC-AMS/Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>18.3.0</Version>
<Version>18.7.0</Version>
</PackageReference>
<PackageReference Include="MSTest">
<Version>4.1.0</Version>
<Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<Version>8.0.1</Version>
<Version>10.0.1</Version>
</PackageReference>
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions JC-AMS/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
<Version>4.9.1</Version>
</PackageReference>
<PackageReference Include="System.IO.Ports">
<Version>10.0.5</Version>
<Version>10.0.9</Version>
</PackageReference>
<PackageReference Condition="'$(TargetFramework)'=='net60-windows'" Include="System.Data.Common" />
<PackageReference Include="System.ServiceProcess.ServiceController">
<Version>10.0.5</Version>
<Version>10.0.9</Version>
</PackageReference>
<PackageReference Include="System.Management">
<Version>10.0.5</Version>
<Version>10.0.9</Version>
</PackageReference>
<PackageReference Include="System.Text.RegularExpressions">
<Version>4.3.1</Version>
Expand Down
29 changes: 22 additions & 7 deletions JC-AMS/Core/Core/System/CSubStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class CSubStation : CPropNotificationClass, IHasParent , IHasID , IXmlSer
/// </summary>
/// <autogeneratedoc />
public static Dictionary<long, CSubStation> SubStations = new Dictionary<long, CSubStation>();

private static readonly object SubStationsSync = new object();
#endregion

#region Interface properties
Expand Down Expand Up @@ -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;
}
}

/// <summary>
Expand All @@ -149,10 +155,13 @@ public CSubStation(CStation cStation, long idSubstation, string sDescription)
/// <autogeneratedoc />
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;
}
}

/// <summary>
Expand All @@ -163,7 +172,10 @@ private void OnChangeIdSubStation(long oldId, long newId, string name)
/// <autogeneratedoc />
private static void RemoveSubStation(long oldId)
{
SubStations.Remove(oldId);
lock (SubStationsSync)
{
SubStations.Remove(oldId);
}
}

#region Interface methods
Expand Down Expand Up @@ -249,7 +261,10 @@ public void WriteXml(XmlWriter writer)
/// <autogeneratedoc />
public static CSubStation GetSubStationGetStation(long idSubStation)
{
return SubStations.ContainsKey(idSubStation) ? SubStations[idSubStation] : null;
lock (SubStationsSync)
{
return SubStations.ContainsKey(idSubStation) ? SubStations[idSubStation] : null;
}
}
#endregion
#endregion
Expand Down
Loading