Skip to main content
2 of 9
added 4 characters in body
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Finish(Asynchronous)Dynamic[]

I have a question deriving from a recent topic Dynamic Variable not Updating.

###Background

Synchronous versus Asynchronous Dynamic Evaluations about the PreemptiveLink:

[...] There is no queue; instead, the front end sends one evaluation at a time and waits for the result before continuing with its other work, [...] the front end is completely locked up, [...]

That is why x won't be updated till the whole expression isn't evaluated (x=2).

Dynamic[x]

   (*We are deliberately ignoring Method->"Queued" to show the point*)
Button["test", x = 1; Pause[1]; x = 2 ]

We can use FinishDynamic[] (link at the top) to ask the FrontEnd to update all Dynamics. When it returns the Kernel can proceed with Pause and the rest.

 Button["test", x = 1; FinishDynamic[]; Pause[1]; x = 2 ]

It will only affect synchronous (default) Dynamics. e.g. Dynamic[x, SynchronousUpdating -> False] won't be triggered.

###The question

This suggests that the MainLink (asynchronous Dynamics) can't be used by a FrontEnd when a preemptive evaluation is going on (even if it is waiting for FinishDynamic[] to return).

Is the last statement correct? Is there any official source confirming that? Maybe it can be deduced from Dynamic related tutorials?


LinkSnooper shows that the FronEnd was asked to update dynamics but with a function UpdateDynamicObjectsSynchronous and returned Null instead of asking for Global`x value. Which is expected since there were no SynchronousDynamicObjects.

Kuba
  • 137.7k
  • 13
  • 289
  • 751