Add CheckForUpdateAsync method for manual update checks and update docs

This commit is contained in:
Stone_Red
2026-02-22 16:06:52 +01:00
parent e3949f2714
commit 95962bf203
2 changed files with 26 additions and 1 deletions
+19 -1
View File
@@ -138,7 +138,7 @@ namespace AlwaysUpToDate
updateTimer.Start();
}
UpdateTimer_Elapsed(null, null);
_ = CheckForUpdateInternalAsync();
}
/// <summary>
@@ -166,7 +166,25 @@ namespace AlwaysUpToDate
}
}
/// <summary>
/// Manually performs a single update check against the remote manifest.
/// Raises <see cref="UpdateAvailable"/> or <see cref="NoUpdateAvailable"/> based on the result.
/// If an update is already in progress, the call is ignored.
/// </summary>
/// <returns>A task that represents the asynchronous check operation.</returns>
/// <exception cref="ObjectDisposedException">The updater has been disposed.</exception>
public async Task CheckForUpdateAsync()
{
ThrowIfDisposed();
await CheckForUpdateInternalAsync();
}
private async void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
await CheckForUpdateInternalAsync();
}
private async Task CheckForUpdateInternalAsync()
{
if (Interlocked.CompareExchange(ref updating, 0, 0) != 0)
{
+7
View File
@@ -143,6 +143,13 @@ private static async void Updater_UpdateAvailable(string version, string changel
}
}
```
### Manually checking for updates
Use `CheckForUpdateAsync()` to trigger a single update check at any time, independently of the timer interval.
`UpdateAvailable` or `NoUpdateAvailable` will be raised as usual when the check completes.
```cs
await updater.CheckForUpdateAsync();
```
This is also useful when the `Updater` is created without a timer interval or with `onlyUpdateOnce: true`, giving full control over when checks occur.
### Update process reporting
```cs
private static void Updater_ProgressChanged(UpdateStep step, long itemsProcessed, long? totalItems, double? progressPercentage)