fix(centralui): safe-invoke fire-and-forget calls in AlarmSummary and TreeView (review 2026-10-21 07/M-4)

This commit is contained in:
Joseph Doherty
2026-10-22 08:39:11 -04:00
parent 420e934eb0
commit 0ebfafa98b
2 changed files with 25 additions and 3 deletions
@@ -449,7 +449,7 @@
private void OnLiveAlarmsChanged(int siteId)
{
if (_disposed) return;
_ = InvokeAsync(() =>
_ = SafeInvokeAsync(() =>
{
// Drop stale callbacks for a site we've since navigated away from, and
// let the poll drive until the aggregator has actually seeded (so we never
@@ -464,6 +464,16 @@
});
}
// Runs the action on the render thread; a callback racing circuit teardown makes
// InvokeAsync throw ObjectDisposedException into an otherwise-unobserved task
// (pattern from DebugView.SafeInvokeAsync).
private async Task SafeInvokeAsync(Action action)
{
if (_disposed) return;
try { await InvokeAsync(action); }
catch (ObjectDisposedException) { /* disposed between the guard and the dispatch */ }
}
// Rebuilds rows/rollup/visible-rows from the live snapshot. Leaves _notReporting
// as the last poll computed it (the alarm-only cache can't know it). Idempotent.
private void ApplyLiveSnapshot(int siteId)