BackgroundTask
Represents background task descriptor that is returned by CreateTask function.
BackgroundTask Properties
Id : Integer
Name : String
Entity name.
User : Identity
The current user during the task execution (usually the one who created the task).
Command : String
Indicates what command to execute (can be built-in command or custom script/view command).
Parameters : Dict
Task command parameters.
Priority : Integer
Task priority (the greater is priority, the more critical is to start the task).
Queue : String
Task queue (tasks with same queue name are executed sequentially, one after another).
CreateTime : DateTime
Task creation time.
UnlockTime : DateTime?
The time when the task will be considered ready to start (scheduled task), or null to start immediately.
StartTime : DateTime?
The time when the task was started, or null if not yet.
FinishTime : DateTime?
The time when the task was finished, or null if not yet.
Status : String
Task status.
- Pending
- InProcess
- Failed
- Succeeded
- Paused
StatusMessage : String
Task status message.
Progress : Integer
Current task progress (between 0 and 100).
Result : Dict
Task result dictionary.
Error : Error
Task error if any.
Paused : Boolean
Shortcut to check if the status is ‘Paused’.
Pending : Boolean
Shortcut to check if the status is ‘Pending’.
InProcess : Boolean
Shortcut to check if the status is ‘InProcess’.
Finished : Boolean
Shortcut to check if the status is ‘Succeeded’ or ‘Failed’.
Succeeded : Boolean
Shortcut to check if the status is ‘Succeeded’.
Failed : Boolean
Shortcut to check if the status is ‘Failed’.
Ready : Boolean
Indicates that the task is ready to be executed.
FailAttempts : Integer
Number of attempts to try re-executing the task if it failed.
Set to -1 to retry until the task succeeds.
CurrentAttempt : Integer
Current attempt (equals 0 on normal execution, 1 on 1st fail attempt).
FailWaitSeconds : Integer
Number of seconds to wait before the next attempt after fail.
FailWaitMultiplier : Integer
Wait multiplier.
The number of seconds to wait is calculated by the formula: FailWaitSeconds * (1 + FailWaitMultiplier * CurrentAttempt).
MaxResults : Integer
Maximum length of the task results history.
Set to 0 (default) to not limit the history, set to -1 to not track results history.
Simulate : Boolean
The task should be running in simulation mode.
Accessible : Boolean
Indicates the current user has access to the task.
The task is accessible to the task owner, to an admin or developer.
Deferred : Boolean
Indicates that the task execution is deferred until the current transaction is finished.
BackgroundTask Methods
History(count = -1, skip = 0) : BackgroundTaskResult[]
Returns the history of the task results.
History Parameters
count : Integer = -1
skip? : Integer
Refresh() : BackgroundTask
Refreshes the task from DB to check its current status.
Wait(ms = -1) : BackgroundTask
Waits for the task to finish.
Wait Parameters
ms : Integer = -1
Number of milliseconds to wait. -1 to wait until the task is finished.
BackgroundTaskResult
Task result history record.
BackgroundTaskResult Properties
StartTime : DateTime
The time when the task was started.
FinishTime : DateTime
The time when the task was finished.
Succeeded : Boolean
Indicates whether the task succeeded or not.
Result : Dict
Task result dictionary.
Error : Error
Task error if any.