# Why is Mathematica limiting the execution time of my calculation? [duplicate]

Is there a Front End option (or programming option) in Mathematica 9 that limits the amount of time that functions take to execute? I have a function (as part of a Mathematica Application) that shows page breaks and iterates though each cell of a notebook. The function operated on large notebooks without problem in Mathematica 8, however in Mathematica 9, it reaches a different point of the notebook each time (and almost gets to the end if page breaks are already showing). The function operates without problem on each half of the notebook (and on smaller notebooks). I have not used any TimeConstraint options. Also note, that I am able to execute the function using Workbench (with Mathematica 9).

The code is executed via a button.

-

## marked as duplicate by Oleksandr R., m_goldberg, Sjoerd C. de Vries, Ajasja, R. M.♦Feb 13 '13 at 20:47

Have you tried adjusting $HistoryLength? – Verbeia Feb 12 '13 at 7:43 A bit more information on what your function actually does and how it is implemented would be very useful. – Yves Klett Feb 12 '13 at 9:57 @Verbeia, Thanks for pointing out$HistoryLength. I did not know of that setting. It was set at Infinity, however changing it to zero did not help – MLD Feb 12 '13 at 23:56
as you say that the code works if called from the workbench, how exactly are you calling this functions (shift-evaluate, button, ...)? So far (?) I don't know of any global time constraints for shift-evaluation and would be very surprised if such constraints would have been introduced, for other ways to call your code I wouldn't be surprised if some default behavior might have changed... – Albert Retey Feb 13 '13 at 1:20
The fact that it's in a button is the entire question. None of your code matters. The question could be boiled down to "Why does Button["wait", Pause[20]; Print["done"]] not complete"? The answer to which is that you should add the option Method->"Queued" as an option to the Button. – John Fultz Feb 13 '13 at 2:29