Fix the crash on changing network settings, and apply resynced contacts in batches

ApplyNetworkSettings disposed the station link without clearing it, so
ApplyStationLinkSettings disposed it a second time and threw. Only the
second function touches the link now, and StationLink.Dispose can be
called twice.

Contacts from the network are queued and applied together on the window
thread. Each one used to rescore the whole log and redraw the log window,
which kept the window thread busy for minutes during a resync.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 00:26:03 +00:00
co-authored by Claude Sonnet 5.5
parent 0e5aa3238b
commit 085584a281
5 changed files with 134 additions and 28 deletions
+6
View File
@@ -54,6 +54,7 @@ public sealed class StationLink : IDisposable
private readonly string computerName;
private readonly string version;
private readonly CancellationTokenSource stopping = new();
private bool disposed;
private readonly ConcurrentDictionary<string, NetworkedStation> stations = new(StringComparer.OrdinalIgnoreCase);
private readonly ConcurrentDictionary<string, TcpClient> writers = new(StringComparer.OrdinalIgnoreCase);
private readonly NetworkedStation mine;
@@ -496,6 +497,11 @@ public sealed class StationLink : IDisposable
public void Dispose()
{
if (disposed)
{
return;
}
disposed = true;
stopping.Cancel();
foreach (TcpClient writer in writers.Values)
{