Modifier

Partager via


TaskScheduler.SetTaskReady(Guid [, DateTime]) Method

Version: Available or changed with runtime version 1.0.

Sets a task that runs a codeunit to the ready state. The task will not run unless it is in the ready state.

Syntax

[Ok := ]  TaskScheduler.SetTaskReady(Task: Guid [, NotBefore: DateTime])

Parameters

Task
 Type: Guid

[Optional] NotBefore
 Type: DateTime

Return Value

[Optional] Ok
 Type: Boolean

Remarks

Scheduled tasks are shown in the Scheduled Tasks page in the client.

If no task exists with the task GUID provided to TaskScheduler.SetTaskReady, then the method will return false (no runtime error will occur).

For more information about the task scheduler, see Using the Task Scheduler.

Example

The following example creates a task, which isn't in IsReady state, then it does some more work, and finally it uses the SetTaskReady method to set the task to ready, but also to start at a later specified time (task ready time + 60 seconds + up to 3 seconds of random time).

var
    TaskID: GUID;
begin
    // Third parameter to TaskScheduler.CreateTask controls IsReady at task creation time
    TaskID := TaskScheduler.CreateTask(CodeUnit::MyCodeUnit, CodeUnit::MyFailureCodeUnit, false);  

    // do something more work needed before starting the task

    // set the task ready and to start after 
    TaskScheduler.SetTaskReady(TaskID, CurrentDateTime + 60*1000 + Random(3000));  
end;

TaskScheduler Data Type
Using the Task Scheduler
Get Started with AL
Developing Extensions