Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I apologize if this is a RTFM question, but I couldn't find this in the docs.

How can I set the timeout of the preemptive link?

For example:

Button["TestShort", Pause[1]; Print["Result"], Method -> "Preemptive"]
Button["TestLong", Pause[10]; Print["Result"], Method -> "Preemptive"]

Clicking on TestLong times out on my system.

share|improve this question
    
Something like Button["TestLong", TimeConstrained[Pause[5]; Print["Result5"], 2, Print@"Failed"], Method -> "Preemptive"] ? –  belisarius Oct 17 '12 at 14:17
    
Not sure if I understand the question –  belisarius Oct 17 '12 at 14:18
    
@belisarius The Preemptive method has a certain timeout. I would like to know what the time limit is and how can I set it. –  Ajasja Oct 17 '12 at 14:22
    
@belisarius Your snippet above always prints Failed –  Ajasja Oct 17 '12 at 14:23
    
@belisarius Sorry for the confusion, DynamicEvaluationTimeout was set to 5 on my system. –  Ajasja Oct 17 '12 at 19:46

2 Answers 2

up vote 8 down vote accepted

In the Option Inspector, there's CellOptionsEvaluation OptionsDynamicEvaluationTimeout which contains that timeout.

As stated in the docs, the value can also be set programmatically using (for this session only):

SetOptions[$FrontEndSession, {DynamicEvaluationTimeout->20.}]

or permanently using

SetOptions[$FrontEnd, {DynamicEvaluationTimeout->20.}]
share|improve this answer
    
@Mr.Wizard: no I think it's there since version 6, but not hardly documented (it is mentioned in tutorial/IntroductionToDynamic) –  Albert Retey Oct 18 '12 at 12:03
    
@Albert thank you, I did not know. –  Mr.Wizard Oct 18 '12 at 12:12
    
@Mr.Wizard: ... and I didn't notice it finally became officially documented and supported in version 8, so thanks for your comment, anyway :-) –  Albert Retey Oct 18 '12 at 12:14

Instead of increasing DynamicEvaluationTimeout globally, it is also possible to just do so locally, e.g. with something like that (as the default is 6, this would timeout with the default setting...):

Style[Button["TestLong", Pause[7]; Print["Result"], 
 Method -> "Preemptive"], DynamicEvaluationTimeout -> 8]

I would, if ever possible, only change such defaults as local as possible: there are good reasons why you want dynamic calculations passed via the preemptive link to timeout. I would also rethink the design of your GUI as in general I believe it's better to use something like Method -> "Queued" instead of tweaking the evaluation timeout: if something takes a long time, it's probably not well fitted to be triggered through the preemptive link...

As far as I can see, the option DynamicEvaluationTimeout exists und seems to works since at least version 6.0.2, but was only documented in version 8 as being new.

share|improve this answer

Your Answer

 
discard

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.