EveryWeeks: Integer;
The EveryWeeks property determines the interval between launches in weeks. By default the calculation is performed every week.
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 Main;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Exe: IExecuteSubScheduledTask;
Per: IScheduledTaskPeriodWeekly;
Prop: IScheduledTaskProperties;
i: Integer;
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.Weekly) As IScheduledTaskPeriodWeekly;
For i := 1 To 5 Do
Per.DaysOfWeek(i As CalendarDayOfWeek) := True;
End For;
Per.EveryWeeks := 2;
Per.StartTime := DateTime.ComposeTimeOfDay(12, 0, 0, 0);
Prop.Period := Per;
MObj.Save;
End Sub Main;
After executing the example a new task of unit execution is created in the scheduled tasks container. The unit will be running from Monday till Friday at 12:00. Interval is week over week.
See also: