Stop and Resume a Task
In Microsoft Project, a task may be stopped temporarily and later resumed. The Stop date marks when the task was interrupted, and the Resume date specifies when work continues. Aspose.Tasks for .NET enables developers to access and modify these values programmatically.
Working with Stopped and Resumed Tasks
The Stop and Resume properties exposed by the Tsk class are used to read or write a task’s stop and resume date:
- Stop: The date when a task is interrupted. (Type: DateTime)
- Resume: The date and time when the task is restarted. (Type: DateTime)
Viewing Stop and Resume Dates in Microsoft Project
To display stop and resume dates in Microsoft Project:
- Open the Task Entry form.
- From the Insert menu, select Column.
- Add the Stop and Resume columns.
If a task has never been interrupted, its Stop and Resume values remain NA.
Example: Reading Stop and Resume Dates
The following example shows how to read and display stop and resume dates for all tasks in a project:
1Project project = new Project("New Project.mpp");
2
3// Create a ChildTasksCollector instance
4ChildTasksCollector collector = new ChildTasksCollector();
5
6// Collect all the tasks from RootTask using TaskUtils
7TaskUtils.Apply(project.RootTask, collector, 0);
8
9// Check Stop and Resume dates for all tasks
10foreach (Task task in collector.Tasks)
11{
12 if (task.Get(Tsk.Stop).ToShortDateString() == "1/1/2000")
13 Console.WriteLine("Stop: NA");
14 else
15 Console.WriteLine("Stop: " + task.Get(Tsk.Stop).ToShortDateString());
16
17 if (task.Get(Tsk.Resume).ToShortDateString() == "1/1/2000")
18 Console.WriteLine("Resume: NA");
19 else
20 Console.WriteLine("Resume: " + task.Get(Tsk.Resume).ToShortDateString());
21}
Key Notes
- By default, tasks without interruptions have Stop and Resume values as NA.
- In Aspose.Tasks evaluation mode, NA values are represented as
"1/1/2000"
. - In licensed mode, NA values are returned as
DateTime.MinValue
. - Both MPP and XML formats are fully supported for reading and writing Stop/Resume properties.
FAQ
Q: Can I set custom stop and resume dates manually?
- Yes. Aspose.Tasks allows assigning any valid
DateTime
value to these fields.
Q: What happens if Stop is later than Resume?
- Microsoft Project enforces logical consistency. Stop must occur before Resume.
Q: Are Stop and Resume the same as Task Start and Finish?
- No. Stop/Resume define interruptions, while Start/Finish define the overall planned timeline.
Q: Does this work for recurring tasks?
- No. Stop and Resume apply only to individual (non-recurring) tasks.