Skip to content

Commit 708df3b

Browse files
BornToBeRootclaude
andauthored
Fix: auto refresh timer bug (#3639)
* Fix: Auto refresh timers and status window close timer - Connections, Listeners, Neighbor Table, WiFi: don't restart the auto refresh timer after a refresh if auto refresh was disabled or the view was hidden in the meantime - WiFi: resume the auto refresh when the view becomes visible (was stopped instead) - Status window: cancel the close timer when the window is opened by the user Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Docs: Separate changelog entries per tool Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Docs: Add PR link to changelog Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f550dbc commit 708df3b

6 files changed

Lines changed: 54 additions & 9 deletions

File tree

‎Source/NETworkManager/StatusWindow.xaml.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ public void ShowWindow(bool enableCloseTimer = false)
151151
return;
152152
}
153153

154+
// Opened by the user, cancel a running close timer (e.g. if the window was opened on a network change)
155+
_dispatcherTimerClose.Stop();
156+
_stopwatch.Stop();
157+
ShowTime = false;
158+
154159
// Focus the window
155160
Activate();
156161
}

‎Source/NETworkManager/ViewModels/ConnectionsViewModel.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e)
9494
// Refresh
9595
await Refresh();
9696

97-
// Restart timer...
98-
_autoRefreshTimer.Start();
97+
// Restart timer, unless auto refresh was disabled or the view was hidden in the meantime
98+
if (AutoRefreshEnabled && _isViewVisible)
99+
_autoRefreshTimer.Start();
99100
}
100101

101102
#endregion
@@ -113,6 +114,7 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e)
113114
/// The timer for auto-refresh.
114115
/// </summary>
115116
private readonly DispatcherTimer _autoRefreshTimer = new();
117+
private bool _isViewVisible = true;
116118

117119
/// <summary>
118120
/// Gets or sets the search text.
@@ -417,6 +419,8 @@ private async Task Refresh(bool init = false)
417419
/// </summary>
418420
public void OnViewVisible()
419421
{
422+
_isViewVisible = true;
423+
420424
// Restart timer...
421425
if (AutoRefreshEnabled)
422426
_autoRefreshTimer.Start();
@@ -427,6 +431,8 @@ public void OnViewVisible()
427431
/// </summary>
428432
public void OnViewHide()
429433
{
434+
_isViewVisible = false;
435+
430436
// Temporarily stop timer...
431437
if (AutoRefreshEnabled)
432438
_autoRefreshTimer.Stop();

‎Source/NETworkManager/ViewModels/ListenersViewModel.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e)
8585
// Refresh
8686
await Refresh();
8787

88-
// Restart timer...
89-
_autoRefreshTimer.Start();
88+
// Restart timer, unless auto refresh was disabled or the view was hidden in the meantime
89+
if (AutoRefreshEnabled && _isViewVisible)
90+
_autoRefreshTimer.Start();
9091
}
9192

9293
#endregion
@@ -104,6 +105,7 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e)
104105
/// The timer for auto-refresh.
105106
/// </summary>
106107
private readonly DispatcherTimer _autoRefreshTimer = new();
108+
private bool _isViewVisible = true;
107109

108110
/// <summary>
109111
/// Gets or sets the search text.
@@ -405,6 +407,8 @@ private async Task Refresh(bool init = false)
405407
/// </summary>
406408
public void OnViewVisible()
407409
{
410+
_isViewVisible = true;
411+
408412
// Restart timer...
409413
if (AutoRefreshEnabled)
410414
_autoRefreshTimer.Start();
@@ -415,6 +419,8 @@ public void OnViewVisible()
415419
/// </summary>
416420
public void OnViewHide()
417421
{
422+
_isViewVisible = false;
423+
418424
// Temporarily stop timer...
419425
if (AutoRefreshEnabled)
420426
_autoRefreshTimer.Stop();

‎Source/NETworkManager/ViewModels/NeighborTableViewModel.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private static string ResourceTranslate(NeighborState state)
8989
private readonly bool _isLoading;
9090

9191
private readonly DispatcherTimer _autoRefreshTimer = new();
92+
private bool _isViewVisible = true;
9293

9394
public string Search
9495
{
@@ -471,12 +472,16 @@ private async Task Refresh(bool init = false)
471472

472473
public void OnViewVisible()
473474
{
475+
_isViewVisible = true;
476+
474477
if (AutoRefreshEnabled)
475478
_autoRefreshTimer.Start();
476479
}
477480

478481
public void OnViewHide()
479482
{
483+
_isViewVisible = false;
484+
480485
if (AutoRefreshEnabled)
481486
_autoRefreshTimer.Stop();
482487
}
@@ -494,7 +499,9 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e)
494499
if (!IsModifying)
495500
await Refresh();
496501

497-
_autoRefreshTimer.Start();
502+
// Restart timer, unless auto refresh was disabled or the view was hidden in the meantime
503+
if (AutoRefreshEnabled && _isViewVisible)
504+
_autoRefreshTimer.Start();
498505
}
499506

500507
#endregion

‎Source/NETworkManager/ViewModels/WiFiViewModel.cs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class WiFiViewModel : ViewModelBase
4141

4242
private readonly bool _isLoading;
4343
private readonly DispatcherTimer _autoRefreshTimer = new();
44+
private bool _isViewVisible = true;
4445
private readonly DispatcherTimer _hideConnectionStatusMessageTimer = new();
4546

4647
public bool SdkContractAvailable
@@ -1301,13 +1302,17 @@ await DialogHelper.ShowMessageAsync(Application.Current.MainWindow, Strings.Erro
13011302

13021303
public void OnViewVisible()
13031304
{
1304-
// Temporarily stop timer...
1305+
_isViewVisible = true;
1306+
1307+
// Restart timer...
13051308
if (AutoRefreshEnabled)
1306-
_autoRefreshTimer.Stop();
1309+
_autoRefreshTimer.Start();
13071310
}
13081311

13091312
public void OnViewHide()
13101313
{
1314+
_isViewVisible = false;
1315+
13111316
// Temporarily stop timer...
13121317
if (AutoRefreshEnabled)
13131318
_autoRefreshTimer.Stop();
@@ -1329,8 +1334,9 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e)
13291334
// Scan networks
13301335
await ScanAsync(SelectedAdapter, true);
13311336

1332-
// Restart timer...
1333-
_autoRefreshTimer.Start();
1337+
// Restart timer, unless auto refresh was disabled or the view was hidden in the meantime
1338+
if (AutoRefreshEnabled && _isViewVisible)
1339+
_autoRefreshTimer.Start();
13341340
}
13351341

13361342
private void HideConnectionStatusMessageTimer_Tick(object sender, EventArgs e)

‎Website/docs/changelog/next-release.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,30 @@ Release date: **xx.xx.2026**
128128

129129
- Fixed errors when changing the network configuration (e.g. missing permissions) not being shown — the change was reported as successful although it failed. The error message of Windows is now shown. [#3606](https://github.com/BornToBeRoot/NETworkManager/issues/3606)
130130

131+
**Connections**
132+
133+
- Fixed the auto refresh continuing in the background after switching to another tool, or after it was disabled, if this happened while a refresh was running. [#3639](https://github.com/BornToBeRoot/NETworkManager/pull/3639)
134+
135+
**Listeners**
136+
137+
- Fixed the auto refresh continuing in the background after switching to another tool, or after it was disabled, if this happened while a refresh was running. [#3639](https://github.com/BornToBeRoot/NETworkManager/pull/3639)
138+
131139
**Neighbor Table**
132140

133141
- Fixed adding and deleting entries not working until the application was restarted if loading the PowerShell module `NetTCPIP` failed once. [cc05937](https://github.com/BornToBeRoot/NETworkManager/commit/cc05937a7de2bf1247621845f47077f3796b9bb2)
142+
- Fixed the auto refresh continuing in the background after switching to another tool, or after it was disabled, if this happened while a refresh was running. [#3639](https://github.com/BornToBeRoot/NETworkManager/pull/3639)
143+
144+
**WiFi**
145+
146+
- Fixed the auto refresh continuing in the background after switching to another tool, or after it was disabled, if this happened while a refresh was running. [#3639](https://github.com/BornToBeRoot/NETworkManager/pull/3639)
147+
- Fixed the auto refresh not being resumed after switching back from another tool. [#3639](https://github.com/BornToBeRoot/NETworkManager/pull/3639)
134148

135149
**Dashboard**
136150

137151
- Fixed the **Network Connection** widget running a full connection check on every application startup, even if the Status Window or Dashboard was never opened. It now only checks when actually shown - via the tray icon, on a network change, or when the Dashboard tab is opened. [#3553](https://github.com/BornToBeRoot/NETworkManager/pull/3553)
138152
- Fixed the DNS status (Computer/Router/Internet) in the **Network Connection** widget showing as an error when no PTR record exists for the address, which is common and expected for private IP ranges. This is now shown as informational instead of critical. [#3553](https://github.com/BornToBeRoot/NETworkManager/pull/3553)
139153
- Fixed a race condition in the **Network Connection** widget where results from a superseded check could overwrite the results of a newer, still-running check after quickly reopening the widget. [#3553](https://github.com/BornToBeRoot/NETworkManager/pull/3553)
154+
- Fixed the Status Window closing by itself after being opened from the tray icon (or with the hotkey), if it was opened automatically on a network change shortly before. [#3639](https://github.com/BornToBeRoot/NETworkManager/pull/3639)
140155

141156
**DNS Lookup**
142157

0 commit comments

Comments
 (0)