Creating Tasks

Contents
[ Hide Show ]

A project is, essentially, made up by a number of tasks, each of which has to be completed for the project to be completed. When working with project files, adding tasks is an important activity. Tasks are often linked to other tasks, to indicate dependency, and typically have a set duration. Aspose.Tasks for C++ API allows developers to create tasks and define name, children and duration at the time of creation.

Creating Tasks

The Task class exposes the Add method for adding a task to a project’s root or other tasks. The following code example demonstrates how to create a task.

The default constructor creates a Task instance without any parameter being passed.

1// Create project instance
2System::SharedPtr<Project> project = System::MakeObject<Project>();
3        
4// Add task, sub task and save project
5System::SharedPtr<Task> task = project->get_RootTask()->get_Children()->Add(u"Summary1");
6System::SharedPtr<Task> subtask = task->get_Children()->Add(u"Subtask1");
7project->Save(dataDir + u"CreateTasks_out.xml", Aspose::Tasks::Saving::SaveFileFormat::XML);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.