FrontEndExecute[FrontEndToken["EvaluatorAbort"]]
is equivalent of the menu item: Evaluation >> Abort
.
It works with signals as explained in Difference between Evaluation>>Quit Kernel and Quit[].
One can use it, from preemptive link, to abort e.g. a loop:
Button["Abort", FrontEndExecute[FrontEndToken["EvaluatorAbort"]],
Method -> "Preemptive"]
While @ True
$Aborted (after click)
Question: I can't do this from ScheduledTasks
, why?
I was expecting here that after first Print
the loop will be broken (you would see cell bracket stop being highlighted, but it is still bold)
RunScheduledTask[
Print[DateString[]];
FrontEndExecute[FrontEndToken["EvaluatorAbort"]];
,
{1, 3}, 5]
While @ True
Few notes:
ScheduledTasks
are returned by Service Link:
but I don't know why this matters.
Related topics:
Aborting from inside a ScheduledTask
Installing LinkSnooper on Windows
What are the purposes of functions in FrontEnd` context