diff --git a/src/Spectre.Console/Widgets/Progress/ProgressTask.cs b/src/Spectre.Console/Widgets/Progress/ProgressTask.cs
index 1df68be..cbc6980 100644
--- a/src/Spectre.Console/Widgets/Progress/ProgressTask.cs
+++ b/src/Spectre.Console/Widgets/Progress/ProgressTask.cs
@@ -71,7 +71,7 @@ namespace Spectre.Console
///
/// Gets a value indicating whether or not the task has finished.
///
- public bool IsFinished => Value >= MaxValue;
+ public bool IsFinished => StopTime != null || Value >= MaxValue;
///
/// Gets the percentage done of the task.
@@ -107,7 +107,8 @@ namespace Spectre.Console
_maxValue = maxValue;
_value = 0;
- _description = description?.RemoveNewLines()?.Trim() ?? throw new ArgumentNullException(nameof(description));
+ _description = description?.RemoveNewLines()?.Trim() ??
+ throw new ArgumentNullException(nameof(description));
if (string.IsNullOrWhiteSpace(_description))
{
throw new ArgumentException("Task name cannot be empty", nameof(description));
@@ -125,13 +126,18 @@ namespace Spectre.Console
{
lock (_lock)
{
+ if (StopTime != null)
+ {
+ throw new InvalidOperationException("Stopped tasks cannot be restarted");
+ }
+
StartTime = DateTime.Now;
StopTime = null;
}
}
///
- /// Stops the task.
+ /// Stops and marks the task as finished.
///
public void StopTask()
{
@@ -292,4 +298,4 @@ namespace Spectre.Console
}
}
}
-}
+}
\ No newline at end of file