Tasks: IMetabaseObjectDescriptors;
The Tasks property returns the list of tasks descriptions that were created in the container.
Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINTER identifier.
Sub UserProc;
Var
MB: IMetabase;
Cont: IScheduledTasksContainer;
Tasks: IMetabaseObjectDescriptors;
MDesc: IMetabaseObjectDescriptor;
Task: IScheduledTask;
Begin
MB := MetabaseClass.Active;
Cont := MB.ItemById("TASK_CONTAINTER").Bind As IScheduledTasksContainer;
Tasks := Cont.Tasks;
For Each MDesc In Tasks Do
Debug.Write("Task: " + MDesc.Name + " State: ");
Task := MDesc.Bind As IScheduledTask;
Select Case (Task.State As Integer)
Case 0: Debug.WriteLine("Inactive");
Case 1: Debug.WriteLine("Ready");
Case 2: Debug.WriteLine("Running");
Case 3: Debug.WriteLine("Finished");
Case 4: Debug.WriteLine("Error");
End Select;
End For;
End Sub UserProc;
After executing the example tasks list and state of each task are displayed in the development environment console.
See also: