Pause#
A gap in a task's work. At is the elapsed time from the task start to the start of the gap, and Length is how long the gap lasts. Pauses go in TaskData.Pauses and in TaskUpdate.Pauses. Project.Level writes them when it splits a task; create one with the constructor or with Pause.Leveling.
Declaration#
namespace Plen;
public sealed class Pause : IDeepCloneable<Pause>, IEquatable<Pause>
Constructors#
Pause(double, double)#
public Pause(double at, double length)
Creates a pause with By = null.
| Name | Type | Description |
|---|---|---|
at |
double |
Elapsed time from the task start to the pause start. |
length |
double |
Elapsed length of the pause. |
Properties#
| Property | Type | Default | Description |
|---|---|---|---|
At |
double |
set by the constructor | Elapsed time from the task start to the pause start. Finite and >= 0. |
Length |
double |
set by the constructor | Elapsed length of the pause. Finite and > 0. |
By |
PauseSource? |
null |
Who wrote the pause. The leveler always sets PauseSource.Leveling. |
At, Length#
public double At { get; set; }
public double Length { get; set; }
Both values are elapsed (wall-clock) time in the task's DurationUnit: a minute, an hour of 60 minutes, or a day of 24 hours. Fractions are allowed. When the task is scheduled, the pause occupies the whole minutes [round(At), round(At + Length)). The two ends are rounded, not At and Length on their own, so adjacent pauses never overlap after rounding. A pause that rounds to zero length is ignored.
A pause only counts while the task has work left after it. For how pauses shape a task's dates, see Leveling resources.
By#
public PauseSource? By { get; set; }
Optional on input. Every pause in a project counts as leveling-owned, whatever By holds. See LevelingOptions for how the leveler clears and extends them.
Static methods#
Leveling#
public static Pause Leveling(double at, double length)
Returns a pause with By = PauseSource.Leveling, the same value the leveler writes.
Methods#
DeepClone#
public Pause DeepClone()
Returns a copy with the same At, Length and By.
Equals#
public bool Equals(Pause? other)
public override bool Equals(object? obj)
Value equality: two pauses are equal when At, Length and By are equal. GetHashCode is consistent with it.
ToString#
public override string ToString()
Returns a readable rendering of At, Length and By, for logging.
PauseSource#
Who created a pause.
namespace Plen;
public enum PauseSource { Leveling }
| Value | Description |
|---|---|
Leveling |
Created by resource leveling. The only value. |
Errors#
A task's pause list is validated when the snapshot is passed to Engine.Schedule or Project.Solve(data, …). The call throws InputException with Kind = InputErrorKind.Validation and Path = "tasks[i].pauses[j]" when pause j:
- has an
Atthat's negative,NaNor infinite - has a
Lengththat's<= 0,NaNor infinite - starts before the previous pause ends, so the list isn't sorted by
Ator two pauses overlap
At = 0 and adjacent pauses (one ends exactly where the next starts) are valid. The overlap check forgives floating-point error up to 1e-9 × max(1, At + Length) of the previous pause, so minute-exact fractions such as 1.0/60 + 31.0/60 against 32.0/60 pass.
The list is validated on every task kind, but pauses have no effect on summaries, milestones and unscheduled tasks.
Validation.Repair clears an invalid list instead of throwing and records a Note.Repaired at tasks[i].pauses. Pause lists changed after the first solve go through TaskUpdate, which runs the same checks.
Example#
A three-day task that stops for a day, one day after it starts:
using Plen;
var start = Moment.FromYmdHm(2026, 4, 6, 8, 0)
?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
Tasks =
[
new TaskData(1)
{
StartDate = start,
Duration = 3.0,
DurationUnit = TimeUnit.Day,
Pauses = [Pause.Leveling(1.0, 1.0)],
},
],
};
var result = Engine.Schedule(data, new SolveOptions());
foreach (var update in result.Updates)
{
Console.WriteLine(update);
}
Related#
TaskData- holds a task's pausesProject.Level- writes pausesLevelingOptions- how the leveler clears and extends pauses- Leveling resources - how leveling splits tasks
- Clear leveling - removing pauses and delays