Skip to content

Add ChangeInterval to change a running action's interval [minor] - #109

Merged
matt-edmondson merged 2 commits into
mainfrom
feat/change-interval-80
Nov 14, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
feat/change-interval-80

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #80

What was wrong

The README's "Dynamic Interval Adjustment" example assigns to IntervalActionOptions.ActionInterval, which is init-only, so it fails to compile with CS8852. It would also have done nothing, because the instance copies its options once in Start and never reads them again. No public API could change the interval. The only way was Stop() followed by a new Start(...), and that loses the last-run timestamp and any pending failure.

Change

  • New IntervalAction.ChangeInterval(TimeSpan) sets the instance's ActionInterval under the lock. Every read of that field already happens under the lock: TryRun, HasIntervalElapsed, and the FromLastCompletion wait extension.
  • The new interval applies from the next poll and is measured from the kept LastRunTimestamp. If the run is already overdue under the new interval, it starts on the next poll; otherwise it waits out the rest. A run in progress is not interrupted. A negative value stops the action from running, the same as it does in Start.
  • The README example now uses ChangeInterval, and the method is in the API table. A line in CLAUDE.md notes the new invariant.

The issue's other point, the README rows for IsRunning/Options, had already been removed on main.

Tagged [minor] because this adds public API.

Tests

  • ChangeIntervalAppliesToTheNextPollMeasuredFromTheLastRun (both interval types): a shorter interval makes an already-elapsed run due.
  • ChangeIntervalToALongerIntervalHoldsOffARunThatWasDue
  • ChangeIntervalSpeedsUpARunningAction: end to end against a live polling loop.

With ChangeInterval turned into a no-op, all four fail. With the fix, the full suite passes (66/66, net10.0), and a Release build of the solution succeeds across all target frameworks with no warnings.


Generated by Claude Code

The README's "Dynamic Interval Adjustment" example assigned to the
init-only IntervalActionOptions.ActionInterval, which does not compile,
and the instance never re-read its options anyway. ChangeInterval sets
the interval under the lock; the next poll measures it from the kept
last run, so a run in progress is not interrupted and no state is lost.

Fixes #80

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW59k83EYpQhgtoH5Qc
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 89c84ad into main Nov 14, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the feat/change-interval-80 branch November 14, 2026 01:45
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.

Running IntervalAction cannot change its interval; README "Dynamic Interval Adjustment" example does not compile

2 participants