Message Boards Message Boards

1
|
5723 Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:

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

Posted 10 years ago

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

POSTED BY: Kuba Podkalicki

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
POSTED BY: Patrick Scheibe
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