diff --git a/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs b/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs index a838f434..4b88913d 100644 --- a/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs +++ b/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs @@ -68,26 +68,33 @@ internal sealed class FleetAlertForm : Form statusCheckTimer.Start(); } - private async void StatusCheckTimer_Tick(object? sender, EventArgs e) + private void StatusCheckTimer_Tick(object? sender, EventArgs e) { if (client == null || hostname == null) return; - try + Task.Run(async () => { - var alerts = await client.FetchAlertsAsync(hostname, CancellationToken.None); - var stillActive = alerts?.Any(a => a.NotificationId == alert.NotificationId) ?? false; - - if (!stillActive) + try { - statusCheckTimer?.Stop(); - Close(); + var alerts = await client.FetchAlertsAsync(hostname, CancellationToken.None) + .ConfigureAwait(false); + var stillActive = alerts?.Any(a => a.NotificationId == alert.NotificationId) ?? false; + + if (!stillActive) + { + BeginInvoke(new Action(() => + { + statusCheckTimer?.Stop(); + Close(); + })); + } } - } - catch - { - // Ignore errors - keep the form open if we can't check status - } + catch + { + // Ignore errors - keep the form open if we can't check status + } + }); } private void ApplyRoundedCorners() diff --git a/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs b/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs index d097b3fb..d9ec6a69 100644 --- a/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs +++ b/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs @@ -159,24 +159,25 @@ internal sealed class FleetAlertWorker : IDisposable private void OnAlertAcknowledged(FleetAlert alert, CancellationToken token) { - try - { - logger.LogInformation( - "Fleet alert {NotificationId} acknowledged; posting to server.", alert.NotificationId); + logger.LogInformation( + "Fleet alert {NotificationId} acknowledged; queuing server post.", alert.NotificationId); - client.AcknowledgeAlertAsync(alert.NotificationId, assetId, hostname, token) - .GetAwaiter() - .GetResult(); + store.MarkAcknowledged(alert.NotificationId); - store.MarkAcknowledged(alert.NotificationId); - logger.LogInformation("Fleet alert {NotificationId} recorded.", alert.NotificationId); - } - catch (Exception exception) + Task.Run(async () => { - logger.LogWarning(exception, - "Could not acknowledge fleet alert {NotificationId}; will retry on next poll.", - alert.NotificationId); - } + try + { + await client.AcknowledgeAlertAsync(alert.NotificationId, assetId, hostname, token); + logger.LogInformation("Fleet alert {NotificationId} posted to server.", alert.NotificationId); + } + catch (Exception exception) + { + logger.LogWarning(exception, + "Could not post acknowledgment for fleet alert {NotificationId}; already marked locally.", + alert.NotificationId); + } + }); } public void Dispose() diff --git a/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj b/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj index 9b788fff..4c2e0398 100644 --- a/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj +++ b/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj @@ -79,7 +79,10 @@ - 1.6.3 + + 1.6.4 true win-x64 true diff --git a/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj b/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj index 6e853e28..1400b34b 100644 --- a/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj +++ b/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj @@ -175,7 +175,9 @@ No agent code changes, but deployed together for version consistency. --> - 1.13.2 + + 1.13.3 true win-x64 true