How to check whether the FrontEnd considers evaluation still running?

断了今生、忘了曾经 提交于 2019-12-07 22:46:27

This should work. Of course, you have to run it in a different kernel than the one that is performing the evaluation you want to check for.

NotebookEvaluatingQ[nb_] := (
 SelectionMove[nb, All, Notebook];
 Or @@ Map["Evaluating" /. # &, Developer`CellInformation[nb]]
)

Obviously, it's best to set things up before hand using a tool like Monitor. For example,

Monitor[
  Do[Pause[6], {i, 10}],
i]

will allow you to observe the progress of the index variable i. If you haven't set things up before hand, you might be able to do something using the "Interrupt Evaluation" button under the Evaluation menu. For example, try the following:

Do[Pause[6], {i, 10}]

Now, wait six or more seconds and then select "Interrupt Evaluation". You can then examine the state of i to see how far along it is. You resume evaluation using Continue under "Debugger Controls".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!