Skip to content

Fix dock band not updating after sleep/hibernation - #141

Merged
michaeljolley merged 1 commit into
mainfrom
dev/mjolley/fix-dock-band-stale-after-sleep
Jun 21, 2026
Merged

Fix dock band not updating after sleep/hibernation#141
michaeljolley merged 1 commit into
mainfrom
dev/mjolley/fix-dock-band-stale-after-sleep

Conversation

@michaeljolley

Copy link
Copy Markdown
Contributor

Problem

After the system resumes from sleep or hibernation, the dock band for a pinned location stops updating its title/subtitle with fresh weather data.

Root cause: An in-flight HTTP request at the time of sleep could hold the _isUpdating re-entrancy guard indefinitely (1), blocking all subsequent timer ticks from executing UpdateWeatherAsync. Additionally, System.Timers.Timer doesn't guarantee an immediate tick on resume, leaving stale data displayed.

Fix

Subscribe to SystemEvents.PowerModeChanged in PinnedWeatherBand and on Resume:

  1. Cancel the stale CancellationTokenSource and swap in a fresh one (via Interlocked.Exchange)
  2. Reset _isUpdating to 0 so updates aren't blocked
  3. Restart the timer for a clean interval from the resume point
  4. Immediately trigger UpdateWeatherAsync() for fresh weather data

The handler is properly unsubscribed in Dispose().

Testing

All 296 existing tests pass. The structural/IL-level tests in DockBandCardSyncTests continue to validate the timer and content-page sync contracts.

After the system resumes from sleep or hibernation, an in-flight HTTP
request could hold the _isUpdating re-entrancy guard indefinitely,
blocking all subsequent timer ticks from refreshing the band's
title/subtitle. The System.Timers.Timer also may not fire immediately
on resume, leaving stale weather data displayed.

Subscribe to SystemEvents.PowerModeChanged and, on Resume:
- Cancel the stale CancellationTokenSource and swap in a fresh one
- Reset _isUpdating so the next update is not blocked
- Restart the timer for a clean interval
- Immediately trigger UpdateWeatherAsync for fresh data

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@michaeljolley
michaeljolley merged commit 9a35212 into main Jun 21, 2026
2 checks passed
@michaeljolley
michaeljolley deleted the dev/mjolley/fix-dock-band-stale-after-sleep branch June 21, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant