topic hubAL Developmentofficial - Microsoftreviewed - checked by Opus

Running things in the background

Background processing in AL for Business Central: page background tasks, Session.StartSession, the task scheduler and the job queue. It answers questions about choosing a mechanism, scheduling codeunits and reports, handling errors and retries, and concurrency and timeout limits online and on-premises.

Path: Development > Programming in the AL language > Running things in the background · tier official · system development · narrative reviewed (checked by Opus)

Overview

This area covers the ways AL code can run work outside the user’s foreground session. An overview page compares the mechanisms: page background tasks, Session.StartSession, the task scheduler and the job queue. It notes that each has limits for concurrency and timeouts, and that these differ between online and on-premises environments.\n\nPage background tasks, the task scheduler and the job queue each have their own page. Page Background Tasks covers read-only computations that keep a page responsive, with parent and child sessions, dictionary parameters, timeouts and error levels. The task scheduler page covers running codeunits and reports at a set date and time, with retry for transient errors and failure codeunits. The job queue page covers end-user scheduling of recurring background jobs through a dispatcher codeunit, with error handling and permissions. A subtopic holds the AL language reference pages for background processing.\n\nStart with the asynchronous processing overview to pick a mechanism and check its limits. Then read the page for that mechanism.

Key points

  • The overview compares page background tasks, Session.StartSession, task scheduler and job queue.
  • Concurrency and timeout limits differ between online and on-premises; settings named include ChildSessionsMaxConcurrency and BackgroundSessionsMaxConcurrent.
  • Page background tasks run read-only computations and long processes without blocking the user.
  • Page background tasks use parent and child sessions, dictionary parameters for input, configurable timeouts, and error levels Ignore, Warning and Error.
  • Page background tasks can be re-enqueued or conditionally cancelled.
  • The task scheduler uses CreateTask, SetTaskReady, TaskExists and CancelTask to run codeunits and reports at a given date and time.
  • The task scheduler retries retriable exceptions and can run failure codeunits.
  • The job queue lets end users schedule recurring background jobs via a dispatcher and an error handler, with parameter passing and permissions.

Subtopics

More Learn pages

Videos, posts and code changes

Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.

Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.

What Learn documents here 7 Learn pages