# Why doesn't 'Abort evaluation' properly work when NotebookEvaluate is executed?

The following procedure can be easily aborted using Evaluation > Abort Evaluation menu item:

Do[j + k, {j, 1, 10000}, {k, 1, 10000}]


But it is not possible if NotebookEvaluate was used:

nb = CreateDocument[ ExpressionCell[Defer[Plot[Sin[x], {x, 0, 2 Pi}]], "Input"]]
NotebookEvaluate[nb, InsertResults -> True];


Now run this again:

Do[j+k,{j,1,10000},{k,1,10000}]


and try to abort. It does not work and the loop is on.

Anyone knows why? Is there any alternative to NotebookEvaluate?

• I rephrased the question and made the example self contained. Feel free to revert my changes. p.s. +1, interesting. – Kuba Jan 18 '19 at 10:22
• @Kuba Thanks! Your rephrase seems great! – Veteran Jan 18 '19 at 10:25
• WRI says it is a 'known issue' so I guess bugs applies. – Kuba Jan 18 '19 at 15:13

file = NotebookOpen[filename];

• It should be noted that this workaround behaves very differently to NotebookEvaluate in a few aspects: NotebookEvaluate evaluates the notebook and waits until it is done, while your method simply enqueues it for evaluation. (Also, the line numbers are different) – Lukas Lang May 10 '19 at 8:01