({{, (RefLink[$CurrentTask, paclet:ref/$CurrentTask]) 
gives the (RefLink[TaskObject, paclet:ref/TaskObject])[…] corresponding to the task in which it is being evaluated.}})

OpenersNotesSection(Spacer1)Details

(RefLink[$CurrentTask, paclet:ref/$CurrentTask]) is set to the current (RefLink[TaskObject, paclet:ref/TaskObject]) when evaluated within the task object or within a handler function for events generated by the task.

If evaluated not within a task object, (RefLink[$CurrentTask, paclet:ref/$CurrentTask]) gives (RefLink[None, paclet:ref/None]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Create a task and show available properties:

SessionSubmit[MessageDialog[$CurrentTask["Properties"]]]

Display task's identifier:

SessionSubmit[MessageDialog[$CurrentTask["TaskUUID"]]]

Print task's current status:

SessionSubmit[ScheduledTask[Print[ToString[$CurrentTask["TaskStatus"]]],{1,3}]]

Print run counts of the task:

SessionSubmit[ScheduledTask[f,{1,3}],HandlerFunctions-><|"ScheduleTriggered"->Print|>,
HandlerFunctionsKeys->{"TotalRunCount", "PreviousRunCount","RemainingRunCount"}]

Print previous and remaining run counts using (RefLink[$CurrentTask, paclet:ref/$CurrentTask]):

SessionSubmit[ScheduledTask[Print[{$CurrentTask["TotalRunCount"],$CurrentTask["PreviousRunCount"],$CurrentTask["RemainingRunCount"]}],{1,3}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TaskObject, paclet:ref/TaskObject])  ▪  (RefLink[HandlerFunctions, paclet:ref/HandlerFunctions])  ▪  (RefLink[$EvaluationCloudObject, paclet:ref/$EvaluationCloudObject])  ▪  (RefLink[$EvaluationEnvironment, paclet:ref/$EvaluationEnvironment])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Background & Scheduled Tasks, paclet:guide/BackgroundAndScheduledTasks])}})}})