Redaguoti

Bendrinti naudojant


TaskScheduler.CancelTask(Guid) Method

Version: Available or changed with runtime version 1.0.

Cancels and deletes a scheduled task that runs a specific codeunit.

Syntax

[Ok := ]  TaskScheduler.CancelTask(Task: Guid)

Parameters

Task
 Type: Guid
Specifies the unique identifier of the task. The unique identifier is returned by the CreateTask method when creating the task.

Return Value

[Optional] Ok
 Type: Boolean

Remarks

Scheduled tasks are shown in the Scheduled Tasks page in the client. The TaskScheduler.CancelTask method removes the task entry from the page (the implementation is different for the on-premises version compared to the online version of Business Central).

The TaskScheduler.CancelTask method can only cancel pending tasks.

If no task exists with the provided task GUID provided to TaskScheduler.CancelTask, then the method returns false (no runtime error occurs).

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

Example

This example shows how to use TaskScheduler.CancelTask to force canceling a task.

procedure CancelTasks(ScheduledTaskId: Guid)
begin
    TaskScheduler.CancelTask(ScheduledTaskId); // Force cancel task 
end;

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