mirror of
https://github.com/Stone-Red-Code/AlwaysUpToDate.git
synced 2026-09-04 00:46:05 +02:00
Add UpdateStarted event to signal when update download begins
This commit is contained in:
@@ -11,6 +11,7 @@ internal class Program
|
|||||||
{
|
{
|
||||||
updater.ProgressChanged += Updater_ProgressChanged;
|
updater.ProgressChanged += Updater_ProgressChanged;
|
||||||
updater.UpdateAvailable += Updater_UpdateAvailable;
|
updater.UpdateAvailable += Updater_UpdateAvailable;
|
||||||
|
updater.UpdateStarted += Updater_UpdateStarted;
|
||||||
updater.NoUpdateAvailable += Updater_NoUpdateAvailable;
|
updater.NoUpdateAvailable += Updater_NoUpdateAvailable;
|
||||||
updater.OnException += Updater_OnException;
|
updater.OnException += Updater_OnException;
|
||||||
updater.Start();
|
updater.Start();
|
||||||
@@ -42,6 +43,11 @@ internal class Program
|
|||||||
Console.WriteLine($"[{step}] {itemsProcessed}/{totalItems} {progressPercentage}%");
|
Console.WriteLine($"[{step}] {itemsProcessed}/{totalItems} {progressPercentage}%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Updater_UpdateStarted(string version)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Starting update to version {version}...");
|
||||||
|
}
|
||||||
|
|
||||||
private static void Updater_NoUpdateAvailable()
|
private static void Updater_NoUpdateAvailable()
|
||||||
{
|
{
|
||||||
Console.WriteLine("You are up to date!");
|
Console.WriteLine("You are up to date!");
|
||||||
|
|||||||
@@ -66,6 +66,17 @@ namespace AlwaysUpToDate
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event ExceptionHandler OnException;
|
public event ExceptionHandler OnException;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the method that will handle notifications when the update process begins.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="version">The version string of the update being installed.</param>
|
||||||
|
public delegate void UpdateStartedHandler(string version);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs once when the update download begins, before the first <see cref="ProgressChanged"/> event.
|
||||||
|
/// </summary>
|
||||||
|
public event UpdateStartedHandler UpdateStarted;
|
||||||
|
|
||||||
private static readonly XmlSerializer manifestSerializer = new XmlSerializer(typeof(UpdateManifest));
|
private static readonly XmlSerializer manifestSerializer = new XmlSerializer(typeof(UpdateManifest));
|
||||||
private readonly HttpClient httpClient = new HttpClient();
|
private readonly HttpClient httpClient = new HttpClient();
|
||||||
private readonly System.Timers.Timer updateTimer = new System.Timers.Timer();
|
private readonly System.Timers.Timer updateTimer = new System.Timers.Timer();
|
||||||
@@ -242,6 +253,8 @@ namespace AlwaysUpToDate
|
|||||||
updateTimer.Stop();
|
updateTimer.Stop();
|
||||||
_ = Interlocked.Exchange(ref updating, 1);
|
_ = Interlocked.Exchange(ref updating, 1);
|
||||||
|
|
||||||
|
UpdateStarted?.Invoke(pendingUpdateItem?.Version);
|
||||||
|
|
||||||
using HttpResponseMessage response = await httpClient.GetAsync(updateUrl);
|
using HttpResponseMessage response = await httpClient.GetAsync(updateUrl);
|
||||||
_ = response.EnsureSuccessStatusCode();
|
_ = response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
|||||||
@@ -51,12 +51,17 @@ updater.Start();
|
|||||||
...
|
...
|
||||||
updater.ProgressChanged += Updater_ProgressChanged;
|
updater.ProgressChanged += Updater_ProgressChanged;
|
||||||
updater.UpdateAvailible += Updater_UpdateAvailible;
|
updater.UpdateAvailible += Updater_UpdateAvailible;
|
||||||
|
updater.UpdateStarted += Updater_UpdateStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Updater_UpdateAvailible(string version, string additionalInformationUrl)
|
private static void Updater_UpdateAvailible(string version, string additionalInformationUrl)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Updater_UpdateStarted(string version)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private static void Updater_ProgressChanged(UpdateStep step, long? totalItems, long itemsProcessed, double? progressPercentage)
|
private static void Updater_ProgressChanged(UpdateStep step, long? totalItems, long itemsProcessed, double? progressPercentage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user