Queue Background Task vs Call Logic Block on the Background-Task Logic Block

I see two ways to invoke a background-task logic block:

  1. Use the Queue Background Task action to queue the background-task logic block
  2. Call the background-task logic block directly

I would think using the Queue Background Task action would be the preferred method since you can control when to queue the task with the Queue Immediately checkbox.

Other than that, what is the best practice?
Should we always use Queue Background Task action to queue the background-task logic block? If I call the backg-ground-task logic block directly, then would there be some side effects?

These actions behave differently based on what thread is calling them, and your choice of whether to Call or Queue should be influenced by these design considerations:

  • Queue Background Logic Block will always result in a new job/thread
  • Call a Logic Block of type background will result in
    • a new background job/thread if the initiating thread is a UI thread executing a type = Transaction LB
    • run inline if the initiating thread is a pre-existing background job

3 Likes

Ian’s reply is spot on. Here is some alternate phrasing if it helps:

Queue a Background Logic Block will always queue up the specified logic block to run in a separate background process. It provides the additional “Queue Immediately” checkbox that [may] specify behavior specific to queueing.

For Call A Logic Block, the difference arises based on where the calling logic block is running:

  • If the calling logic block is running synchronously (e.g. as part of a Field Value Changed action), the called logic block will be queued to run in the background.
  • If the calling logic block is running asynchronously (e.g. as a Job or part of an automatic Workflow transition) then the called logic block will run in-line, since it is already in the Background.
3 Likes

@ian.p + @brendan.b, thanks to the explanations and a nice picture; it is worth a thousand words.