Setting the Stage of a JobProgressReporter now updates progress instantly

This commit is contained in:
Dominion
2023-04-24 18:35:51 -04:00
parent b2f571a92d
commit 71577d1ea3
@@ -14,7 +14,18 @@ namespace Tgstation.Server.Host.Jobs
/// <summary>
/// The name of the current stage.
/// </summary>
public string StageName { get; set; }
public string StageName
{
get => stageName;
set
{
if (stageName == value)
return;
stageName = value;
callback(stageName, lastProgress);
}
}
/// <summary>
/// The <see cref="ILogger{TCategoryName}"/> for the <see cref="JobProgressReporter"/>.
@@ -26,6 +37,16 @@ namespace Tgstation.Server.Host.Jobs
/// </summary>
readonly Action<string, double?> callback;
/// <summary>
/// Backing field for <see cref="StageName"/>.
/// </summary>
string stageName;
/// <summary>
/// The last progress value pushed into the <see cref="callback"/>.
/// </summary>
double? lastProgress;
/// <summary>
/// The total progress reported so far in this section.
/// </summary>
@@ -66,6 +87,7 @@ namespace Tgstation.Server.Host.Jobs
sectionProgression = progress.Value;
callback(StageName, clampedProgress);
lastProgress = clampedProgress;
}
/// <summary>