Critical and Effort-Driven Tasks

Microsoft Project recognized a number of different types of tasks. Tasks with no duration, for example, are considered milestones by default. Critical tasks make up the critical path, one or a series of tasks that, ultimately, determines how long a project will take.

Working with Critical and Effort-Driven Tasks

The Tsk class exposes the IsCritical and IsEffortDriven properties to handle critical and effort driven tasks:

Critical and Effort-driven Tasks in Microsoft Project

To check whether a task is critical or effort-driven in Microsoft Project double-click a task in the Task Entry form:

check is task effort driven in Microsoft Project

Getting Critical and Effort-Driven Tasks

The following code examples demonstrate how to get information about whether a task is critical or effort-driven.

 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"CriticalEffortDrivenTasks.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// Parse through all the collected 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        System::String strED = tsk1->Get<NullableBool>(Tsk::IsEffortDriven()).get_Value() ? System::String(u"EffortDriven") : System::String(u"Non-EffortDriven");
21        System::String strCrit = tsk1->Get<NullableBool>(Tsk::IsCritical()).get_Value() ? System::String(u"Critical") : System::String(u"Non-Critical");
22        System::Console::WriteLine(tsk1->Get(Tsk::Name()) + u" : " + strED);
23        System::Console::WriteLine(tsk1->Get(Tsk::Name()) + u" : " + strCrit);
24    }
25}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.