$ScheduledTask

$ScheduledTask
returns within a scheduled task the ScheduledTaskObject or CloudObject for the task.

DetailsDetails

  • If it is evaluated not within a scheduled task, $ScheduledTask gives None.
  • $ScheduledTask is used to refer to the task within a task evaluation, e.g., to learn the parameters or stop the task.

ExamplesExamplesopen allclose all

Basic Examples  (8)Basic Examples  (8)

Print the running scheduled task object:

In[1]:=
Click for copyable input
Out[1]=

Print its time specification:

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input

Remove the scheduled task automatically when it is not needed:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input

Create a task with random wait periods:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
In[4]:=
Click for copyable input

Create a task that restarts evaluation as soon as it finishes:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input

Create a task that runs only once and removes itself after finishing:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Create a task that removes itself once a condition is met:

In[1]:=
Click for copyable input

Create a task that removes itself when an external variable is changed:

In[1]:=
Click for copyable input

Cause the task to be stopped and removed:

In[2]:=
Click for copyable input
Out[2]=

Synchronize scheduled tasks using an auxiliary task:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input

The auxiliary task was removed:

In[5]:=
Click for copyable input
Out[5]=

Stop all scheduled tasks:

In[6]:=
Click for copyable input
Introduced in 2010
(8.0)
| Updated in 2014
(10.0)