Is there a way to check programmatically whether the FrontEnd considers evaluation still running? Or even better: is there a way to check whether the FrontEnd has some pending inputs to be sent to the kernel?
P.S. This question has arisen from previous question.
EDIT
When evaluating a Cell in the FrontEnd we usually create a queue of inputs for the kernel.
I need a function that will return True
if the FrontEnd has sent to the kernel the last input of the queue of inputs from the EvaluationNotebook[]
. Or in other words I need a function that returns True
if this current input is the last input of the queue of inputs generated by the FrontEnd.
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".
来源:https://stackoverflow.com/questions/5643302/how-to-check-whether-the-frontend-considers-evaluation-still-running