Skip to content

TaskStepList

Class in Oadm.Sdk.Plugins · Oadm.Sdk.dll

The step list of one task: the state machine behind ITaskExecutionContext.PlanSteps and ITaskExecutionContext.BeginStep. Used by the server and usable by test fakes, so plugin tests see exactly the server’s step semantics. Thread-safe; TaskStepList.Changed is raised after every change, outside the lock.

public sealed class TaskStepList
TaskStepList(TimeProvider? timeProvider = null, Action<string>? onWarning = null)

Parameters

  • timeProvider: Clock for the step times; the system clock when null.
  • onWarning: Called with the message of ITaskStep.Warn (the task warning).
int Count { get; }

Number of steps.

int CurrentIndex { get; }

Index of the running step; else of the last step that ended (the failed one of a failed task); -1 when no step started yet.

int? Progress { get; }

Overall progress derived from the steps (0-100): every finished step counts as one, the running one with its own progress. Null without steps.

ITaskStep Begin(string name)

Starts a step. A still running step is completed first. A pending (planned) step with this name is activated and moved before the other pending steps; otherwise a new step is inserted there.

void Close(bool succeeded, string skipReason)

For hosts, when the task ends: a running step ends Done (succeeded) or Failed, pending steps become Skipped with skipReason. On success a final step TaskStepList.CompletedStepName (Done) is appended, also beyond TaskStepList.MaxSteps. Later changes are ignored.

static int CurrentIndexOf(IReadOnlyList<TaskStepInfo> steps)

The running step’s index; else the last step that started (the failed one of a failed task), else the last one that ended; -1 when there is none.

bool FailCurrent(string message)

For hosts, when the plugin threw: the running step, else the step just ended by Dispose, becomes Failed with message. Returns false when no step was affected.

void Plan(IEnumerable<string> names)

Appends pending steps; names already pending are not added twice.

IReadOnlyList<TaskStepInfo> Snapshot()

Every step as it is now, in order.

event EventHandler? Changed

Raised after every change of a step.

const string CompletedStepName = "Completed"

Name of the step TaskStepList.Close appends when a task succeeds (Done or Done with warnings), so the current step of a finished task reads “Completed”. Failed and cancelled tasks get none.

const int MaxDetailLength = 1000

Longer details are shortened.

const int MaxNameLength = 200

Longer step names are shortened.

const int MaxSteps = 200

Steps beyond this count are not recorded (their handles still work but change nothing).