Message Boards Message Boards

GROUPS:

Can I abort main evaluation from ScheduledTasks (Service Link)?

Posted 5 years ago
2792 Views
|
1 Reply
|
3 Total Likes
|

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: enter image description here

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

Go here to read the full answer and upvote it. The final solution seems to be to use

RunScheduledTask[Print[DateString[]];
 LinkWrite[First[$FrontEnd], FrontEndToken["EvaluatorAbort"]];, {1, 
  3}, 5]
While@True
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract