mirror of
https://github.com/Stone-Red-Code/AlwaysUpToDate.git
synced 2026-09-04 00:46:05 +02:00
Add CheckForUpdateAsync method for manual update checks and update docs
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user