Stopping and Resuming a Task

A tasks’ 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.

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:

Microsoft Project view of Stop and Resume Dates

To see a task’s stop and resume dates:

  1. In the Task Entry form, on the Insert menu, select Column.
  2. 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 for C++ API takes the value “1/1/2000” if you’re using the evaluation version. When fully licensed, Aspose.Tasks for C++ API uses DateTime.MinValue for NA values. The following code example demonstrates the stop and resume dates for all the tasks in a project.

 1// Read project from file stream
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<System::IO::FileStream> fs = System::MakeObject<System::IO::FileStream>(dataDir + u"StopResumeDates.mpp", System::IO::FileMode::Open);
 4System::SharedPtr<Project> prj = System::MakeObject<Project>(fs);
 5fs->Close();
 6    
 7// Create a ChildTasksCollector instance
 8System::SharedPtr<ChildTasksCollector> collector = System::MakeObject<ChildTasksCollector>();
 9    
10// Collect all the tasks from RootTask using TaskUtils
11TaskUtils::Apply(prj->get_RootTask(), collector, 0);
12    
13// Check Stop and Resume dates for all tasks
14    
15{
16    auto tsk1_enumerator = (collector->get_Tasks())->GetEnumerator();
17    decltype(tsk1_enumerator->get_Current()) tsk1;
18    while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
19    {
20        if (tsk1->Get<System::DateTime>(Tsk::Stop()).ToShortDateString() == u"1/1/2000")
21        {
22            System::Console::WriteLine(u"Stop: NA");
23        }
24        else
25        {
26            System::Console::WriteLine(System::String(u"Stop: ") + tsk1->Get<System::DateTime>(Tsk::Stop()).ToShortDateString());
27        }
28        
29        if (tsk1->Get<System::DateTime>(Tsk::Resume()).ToShortDateString() == u"1/1/2000")
30        {
31            System::Console::WriteLine(u"Resume: NA");
32        }
33        else
34        {
35            System::Console::WriteLine(System::String(u"Resume: ") + tsk1->Get<System::DateTime>(Tsk::Resume()).ToShortDateString());
36        }
37    }
38}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.