Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to trigger a long calculation inside a dynamic module with a Button. It seems that the evaluation stops without an error-message after some seconds. I made a test outside the a dynamic module:

Button["run", res = Total[Table[i; Pause[1], {i, 1, 3}]]]

After pressing the button, the result is: 3 Null

Ok but if the calculation takes 6 seconds

Button["run", res = Total[Table[i; Pause[1], {i, 1, 6}]]]

Then res is not assigned.

Why does it happen and how can it be avoided, also inside a DynamicModule. I would like something like this:

  • Button to start a simulation run

  • Another Button which does some analysis on the simulation results

share|improve this question
up vote 9 down vote accepted

This behaviour is explained in the documentation of Button under Examples > Options > Method. By default, button functions are evaluated on a preemptive link which times out after 5 seconds. To prevent the code from timing out you can set Method -> "Queued" which will run the code on the main link.

share|improve this answer
You can also directly change the DynamicEvaluationTimeout option value, but that is not recommended - – Chris Degnen Jul 2 '12 at 13:45
Thanks! That was exactly what I wanted. – gogoolplex Jul 2 '12 at 13:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.