If you have an Abort[]
inside a ScheduledTask
expression, what does it abort? The scheduled task evaluation, or any main kernel evaluation that is ongoing?
1 Answer
Abort[]
inside a scheduled task will abort the rest of the task expression at the given time, not any main evaluation. It will also repeat to evaluate the task (up till the Abort[]
) if further time slots are scheduled.
To show this, first start a scheduled task:
RunScheduledTask[
Print[DateString[], " Scheduled task before Abort[]"]; Abort[];
Print[DateString[], " Scheduled task after Abort[]"], {5, 3}, 5]
By itself you can see that the scheduled task expression gets aborted: in the Messages window you will see the "before" Print output, but not the "after".
While this is running, start a long-running evaluation in a cell:
Print["Mersenne primes:"];
Do[
With[{n = 2^i - 1, i = i},
If[PrimeQ[n], Print[HoldForm[2^i - 1 == n]]]
],
{i, 10^6}
]
This keeps evaluating even when the scheduled task issues its Abort
.
-
$\begingroup$ I have included some clarification, hope you don't mind! $\endgroup$ Commented Dec 10, 2013 at 20:51
-
-
$\begingroup$ @JoelKlein After starting the long-running evaluation I do not see messages from the
ScheduledTask
no more (I use v. 8.0.4). Why this happens? $\endgroup$ Commented Dec 13, 2013 at 19:13
Button
by default)? Is the functionality exactly the same asInternal`Periodicals
or different? $\endgroup$