What is the preferred way to check if a scheduled task is active?
I will describe my solution below, but I'm not sure if this is really the best way to do this.
The planned task is created as follows:
In[1]:= myTask=CreateScheduledTask[Print["task 1"], 30]
Out[1]= ScheduledTaskObject[1,Print[task 1],{30,Infinity},Automatic,False]
We can check existing tasks as follows:
In[2]:= ScheduledTasks[]
Out[2]= {ScheduledTaskObject[1,Print[task 1],{30,Infinity},Automatic,False]}
The last entry in ScheduledTaskObject( Trueor False) appears, indicating whether the task is running or not.
Now run the task and compare the contents of the variable myTaskwith the list returned ScheduledTasks[].
In[3]:= StartScheduledTask[myTask]
Out[3]= ScheduledTaskObject[1,Print[task 1],{30,Infinity},Automatic,False]
In[4]:= {ScheduledTasks[],myTask}
Out[4]= {{ScheduledTaskObject[1,Print[task 1],{30,Infinity},Automatic,True]},
ScheduledTaskObject[1,Print[task 1],{30,Infinity},Automatic,False]}
, . False, ScheduledTasks[] false. , . myTask , . ScheduledTasks[].
, ScheduledTaskObject , . , , , , "", 1 :
Cases[ScheduledTasks[], ScheduledTaskObject[1,__,state_] :> state]
, ( ScheduledTaskObject) . , (, - - , , ), ScheduledTasks[] ( 0).
:
EDIT: , , , CPU. - , ?