Stop and Resume a Task
A task’s stop date is the date that it should (or did) end. Sometimes, a task has to be stopped temporarily and then resumed later. Microsoft Project can calculate stop dates, or let users enter them manually.
Code Examples
VSTO
Below is the code of VSTO Project to Stop and Resume a task:
1object missingValue = System.Reflection.Missing.Value;
2
3Application.FileOpenEx("MyProject.mpp",
4
5 missingValue, missingValue, missingValue, missingValue,
6
7 missingValue, missingValue, missingValue, missingValue,
8
9 missingValue, missingValue, PjPoolOpen.pjPoolReadOnly,
10
11 missingValue, missingValue, missingValue, missingValue,
12
13 missingValue);
14
15Project project = Application.ActiveProject;
16
17Task MyTask = project.Tasks[1];
18
19// Stop a Task
20
21dynamic StoppedDate = MyTask.Stop;
22
23// Resume a Task
24
25dynamic ResumeDate = MyTask.Resume;
This VSTO example shows how to access the stop and resume dates of a task in a Microsoft Project file. After opening the MPP file and retrieving the active project, the code selects a task by index and reads its Stop
and Resume
properties. These values indicate when the task was paused and when it is scheduled to continue, which is useful for tracking work interruptions or adjusting project timelines.
Aspose.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 a task stops (DateTime).
Resume: the data and time a task restarts (DateTime).
Microsoft Project view of Stop and Resume Dates
To see a task’s stop and resume dates:
In the Task Entry form, on the Inset menu, select Column.
Add the Stop and Resume columns.
Getting Stop and Resume Dates
The stop and resume dates are NA, if the task has never stopped. For date values equal to NA, Aspose.Tasks takes the value “1/1/2000” if you’re using the evaluation version. When fully licensed, Aspose.Tasks uses DateTime.MinValue for NA values. The following examples displays the stop and resume dates for all the tasks in a project.
1Project project = new Project("MyProject.mpp");
2
3Task MyTask = project.RootTask;
4
5// Stop a Task
6
7DateTime StoppedDate = MyTask.Stop;
8
9// Resume a Task
10
11DateTime ResumeDate = MyTask.Resume;
This Aspose.Tasks example demonstrates how to retrieve the stop and resume dates of a task. After loading the project file, it accesses a task (in this case, the root task) and reads its Stop
and Resume
properties. If the task has never stopped, these properties return DateTime.MinValue
when using a licensed version, or “1/1/2000” in evaluation mode. This helps developers identify interruptions in task execution and adjust project tracking accordingly.