In this article, you will learn about 4 ways to boost performance with a background process in Microsoft Dynamics 365 Business Central. These methods are Page Background Tasks, the StartSession function, the Task Scheduler, and the Job Queue. Also, you will find the difference between them and how to apply each one depending on the scenario.

  • Why Should I Use A Background Process?
  • Page Background Tasks
  • The StartSession Function
  • The TaskScheduler
  • The Job Queue

Why Should I Use A Background Process?

Simply put, because you will boost the performance and improve the user interface response times. Removing unnecessary blockings and wait times. Contributing to an overall better user experience.

The objective is to take advantage of the tools provided by Microsoft to run asynchronous and parallel processes. Offloading heavy tasks to a background process.

This post is a compilation of 4 different articles. In this one, you will learn the advantages and disadvantages of each method. Letting you decide which one to apply depending on the situation. For further detail on how to use each method follow the links provided.

Page Background Tasks

A Page Background Task will invoke a child session for executing the heavy processes. Freeing the UI while it performs the calculations.

Page Background Tasks are bound to pages. Meaning that they must be invoked from pages and can only perform read transactions, not writing. They are easy to use and can handle errors.

A Page Background Task is the best way to get heavy reading calculations without blocking the user interface. It´s the perfect use for Factboxes and Role Center Cues.

For further detail on Page Background Tasks follow the article below:

The StartSession Function

The StartSession function is a fast way for creating a background session. It can perform read and write operations. However, there are some disadvantages to keep in mind.

Unlike Page Background Tasks, there is no error handling mechanism. Also, if a restart of the service occurs and the process is caught in the middle it will be stopped. Then, you will need to run it again manually. The Task Scheduler and The Job Queue do survive a server restart.

Note that it must be used carefully. You could end up creating sessions in a loop and consuming all resources. Which would lead to a crash of the service.

For further detail on the StartSession function follow the article below:

The TaskScheduler

The Task Scheduler has the possibility to run heavy reading and writing transactions in a background session. It can also be scheduled. However, you can´t program recurrence tasks directly on it. For that, we need to use the Job Queue. It won´t log the results of the operations either. This is also a feature of the Job Queue.

Other points in favor are that it survives server restarts and can handle errors.

For further detail on the Task Scheduler follow the article below:

The Job Queue

The Job Queue runs on top of the Task Scheduler and has all its advantages. In addition, tasks can be scheduled to be recurrent and the results are automatically logged in Business Central. This is one of the most popular tools for scheduling heavy recurrent tasks that can run out of working hours. Keeping blocking tasks for times when users aren´t using Business Central.

For further detail on how to use Job Queues and for learning some tips follow the article below:

Check Microsoft documentation for further explanations on these four methods.

Also, check Waldo´s presentation on BC TechDays 2022. He has some great performance examples at min 1:06:20.

That´s all. Hope you find it useful.

4 Ways To Boost Performance With Background Processes In Business Central

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *