Re: Problems with ChoiceDialog inside a Dynamic: Bug or not (well)
- To: mathgroup at smc.vnet.net
- Subject: [mg107838] Re: Problems with ChoiceDialog inside a Dynamic: Bug or not (well)
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Sun, 28 Feb 2010 04:53:10 -0500 (EST)
- References: <hmakpo$buu$1@smc.vnet.net>
Hi, > Synchronous Dynamics (which is what you get by default) are stop-the-world sorts > of evaluations. When they're running, any ongoing kernel computation is > completely halted, and the Dynamic evaluation is completely uninterruptible. > Even another Dynamic evaluation cannot interrupt it. Likewise, the front end is > locked into a mode where it can only respond to a very limited number of events > while it awaits the resolution of the Dynamic. > > For this reason, all synchronous Dynamics are evaluated, by default, with a > TimeConstrained wrapper using a time derived from the EvaluationDynamicTimeout > option in the kernel. This option can be tailored on a per-Dynamic basis if you > like using the Style[] function to set the option. The goal is that absolutely > no Dynamic should be allowed to lock up the front end and kernel in such away > that they appear unresponsive to users. > > ChoiceDialog[], or any other function which awaits user input, causes the kernel > to wait for results, but doesn't stop the timer in TimeConstrained[] from > expiring. > > Any Dynamic which you expect to take a long time should be using > SynchronousDynamic->False. This causes the Dynamic to be put into the same > queue as Shift+Enter evaluations, and it can take as long as you want. So it's > not evaluated urgently, but there will be no need for it to evaluate urgently, > either. > > Incidentally, the same thing applies with Method->{"Queued"} (as opposed to > "Preemptive") in Button and ActionMenu. I hear your words, but probably don't understand.... While my experience shows that Method->"Queued" in Buttons and ActionMenus fixes any problems with kernel blocking dialogs, using SynchronosUpdating->False (I guess that's what you meant) does not help, at least with my version 7 on Windows XP this also hangs: DynamicModule[{planets, x, habitantq}, planets = {"Mercury", "Venus", "Earth"}; x = First[planets]; Column[{ PopupMenu[Dynamic[x, {x = #; If[StringMatchQ[x, "Earth"], habitantq = ChoiceDialog[Column[{"Do you live on earth?"}], {"Yes" -> True, "No" -> False}]]} &, SynchronousUpdating -> False], planets], Dynamic[x], Dynamic[habitantq] }]] and so does this: DynamicModule[{planets, x, habitantq}, planets = {"Mercury", "Venus", "Earth"}; x = First[planets]; Column[{ PopupMenu[Dynamic[x, {x = #; If[StringMatchQ[x, "Earth"], habitantq = ChoiceDialog[Column[{"Do you live on earth?"}], {"Yes" -> True, "No" -> False}]]} &, SynchronousUpdating -> False], planets], Dynamic[x, SynchronousUpdating -> False], Dynamic[habitantq, SynchronousUpdating -> False] }]] is there any known way to get something like this working? regards, albert