({{, (RefLink[TaskObject, paclet:ref/TaskObject])[spec] 
is an object that represents a background task.}})

OpenersNotesSection(Spacer1)Details

Tasks are created by functions such as (RefLink[SessionSubmit, paclet:ref/SessionSubmit]), (RefLink[LocalSubmit, paclet:ref/LocalSubmit]) and (RefLink[CloudSubmit, paclet:ref/CloudSubmit]).

(RefLink[TaskObject, paclet:ref/TaskObject])[spec][prop] gives the value of a property of a task.

Properties of all tasks include:

The expression to evaluate is returned wrapped in (RefLink[HoldForm, paclet:ref/HoldForm]).

The most recent values of handler functions keys given by "EventData" are returned as an association. If a particular key has not yet been set, it is returned as (RefLink[Missing, paclet:ref/Missing])[…].

Scheduled tasks have the following additional properties:

A list of all available properties of a task object obj can be obtained using obj["Properties"].

Possible task statuses include:

Possible task types include: "Immediate", "Asynchronous", "Scheduled" and "Continuous".

(RefLink[Normal, paclet:ref/Normal])[obj] gives a representation of a (RefLink[TaskObject, paclet:ref/TaskObject]) as an association.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Run a task in the current session:

obj=SessionSubmit[Pause[3];MessageDialog["Hello!"]]

Convert a (RefLink[TaskObject, paclet:ref/TaskObject]) to (RefLink[Association, paclet:ref/Association]):

Normal[obj]

Create a task:

obj=SessionSubmit[ScheduledTask[Print[DateString[]],{1,100}]]

Look up a task's UUID:

obj["TaskUUID"]

Look up available task properties:

obj["Properties"]

Get an (RefLink[Association, paclet:ref/Association]) representing the task:

Normal[obj]

TaskRemove[obj]

Run a task in a separate kernel:

obj=LocalSubmit[Sort[RandomInteger[10,10000]]]

Normal[obj]

Run a cloud-based task:

obj=CloudSubmit[SendMail[$MachineName]]

Normal[obj]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Tasks, paclet:ref/Tasks])  ▪  (RefLink[$CurrentTask, paclet:ref/$CurrentTask])  ▪  (RefLink[TaskSuspend, paclet:ref/TaskSuspend])  ▪  (RefLink[TaskResume, paclet:ref/TaskResume])  ▪  (RefLink[TaskRemove, paclet:ref/TaskRemove])  ▪  (RefLink[TaskExecute, paclet:ref/TaskExecute])  ▪  (RefLink[TaskWait, paclet:ref/TaskWait])  ▪  (RefLink[SessionSubmit, paclet:ref/SessionSubmit])  ▪  (RefLink[LocalSubmit, paclet:ref/LocalSubmit])  ▪  (RefLink[CloudSubmit, paclet:ref/CloudSubmit])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Background & Scheduled Tasks, paclet:guide/BackgroundAndScheduledTasks])}, {▪(RefLinkPlain[Date & Time, paclet:guide/DateAndTime])}, {▪(RefLinkPlain[Using Connected Devices, paclet:guide/UsingConnectedDevices])}})}})