TimeInterval: DateTime;
The TimeInterval property determines the time interval after which the task is started.
Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINTER identifier and a unit with the Module_1 identifier. The unit contains the Main procedure.
Sub UserProc;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Exe: IExecuteSubScheduledTask;
Per: IScheduledTaskPeriodTimely;
Prop: IScheduledTaskProperties;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_TASK_EXECUTESUB;
CrInfo.Id := "MODULE_EXECUTOR";
CrInfo.Name := "Unit execution";
CrInfo.Parent := MB.ItemById("TASK_CONTAINTER");
MObj := MB.CreateObject(CrInfo).Edit;
Exe := MObj As IExecuteSubScheduledTask;
Exe.Assembly := (MB.ItemById("Module_1").Bind As IModule).Assembly;
Exe.SubName := "Main";
Prop := Exe.Properties;
Per := Prop.CreatePeriod(ScheduledTaskPeriodType.Timely) As IScheduledTaskPeriodTimely;
Per.StartDateTime := DateTime.Now;
Per.TimeInterval := DateTime.ComposeTimeOfDay(0, 30, 0, 0);
Prop.Period := Per;
MObj.Save;
End Sub UserProc;
After executing the example a new task of unit execution is created in the scheduled tasks container. The unit will be running every thirty minutes starting from the current moment.
See also: