Skip to content
Merged
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
12 changes: 10 additions & 2 deletions Dashboard/ServerTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ private async void StartAutoRefreshLoop(int intervalSeconds)
{
await Task.Delay(TimeSpan.FromSeconds(intervalSeconds), cts.Token);
if (cts.Token.IsCancellationRequested) break;
if (_isRefreshing) continue;

try
{
Expand All @@ -384,6 +385,11 @@ private async void StartAutoRefreshLoop(int intervalSeconds)
FooterText.Text = $"Last refresh: {DateTime.Now:yyyy-MM-dd HH:mm:ss} | Server: {_serverConnection.DisplayName}";
Logger.Info($"Auto-refresh completed in {sw.ElapsedMilliseconds}ms for {_serverConnection.DisplayName}");
}
catch (OperationCanceledException) when (!cts.Token.IsCancellationRequested)
{
// SQL query cancelled or timed out, but our loop CTS is still alive — keep going
Logger.Error($"Auto-refresh query cancelled for {_serverConnection.DisplayName}, continuing loop");
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
Logger.Error($"Auto-refresh error: {ex.Message}", ex);
Expand All @@ -393,13 +399,15 @@ private async void StartAutoRefreshLoop(int intervalSeconds)
}
catch (OperationCanceledException)
{
// Normal shutdown
Logger.Info($"Auto-refresh loop stopped for {_serverConnection.DisplayName}");
}
}

private void ServerTab_Unloaded(object sender, RoutedEventArgs e)
{
_autoRefreshCts?.Cancel();
// Don't cancel auto-refresh on tab switch — WPF fires Unloaded when
// a TabItem is deselected, not just when the control is destroyed.
// The loop is lightweight and should keep ticking in the background.
_autoRefreshTimer?.Stop();
_autoRefreshTimer = null;

Expand Down
Loading