I have two notebooks open, one has a dynamic expression running (a simple clock)

Dynamic[{d, h, m, s} = 
  List @@ DateDifference[Now, 
     DateObject[{2015, 5, 18}], {"Day", "Hour", "Minute", 
      "Second"}][[1]];
   Grid[Transpose @ {{"d", d}, {"h", h}, {"m", m}, {"s", Round@s}}, 
       Alignment -> Left], UpdateInterval -> 1]

And while this is running, it interferes strongly with the Dynamic expression in my other notebook, even when the notebook is offscreen or minimized. Is there any safeguard for these dynamics bringing the frontend to a crawl?

  • Launch the notebooks in separate kernels running on separate cores (assuming you have a multi-core machine) with LaunchKernels[2]. – David G. Stork Apr 7 '15 at 17:06
  • 3
    Wrap both dynamic expressions with DynamicModule and localize your variables there. – Sjoerd C. de Vries Apr 7 '15 at 19:40
  • @DavidG.Stork What is the relation between kernels and dynamics, I thought that for Dynamic's the FE was the bottleneck. – M.R. Apr 7 '15 at 20:17
  • @M.R. A Dynamic's front end may or may not be the computational bottleneck, depending upon the algorithms, the complexity of the rendering, and so forth. – David G. Stork Apr 7 '15 at 20:25

You may consider moving the variables used for the dynamic clock into a dedicated context

Dynamic[{clock`d, clock`h, clock`m, clock`s} = 
  List @@ DateDifference[Now, 
     DateObject[{2015, 5, 18}], {"Day", "Hour", "Minute", 
      "Second"}][[1]];

Grid[Transpose@{{"d", clock`d}, {"h", clock`h}, {"m", clock`m}, {"s",
      Round@clock`s}}, Alignment -> Left], UpdateInterval -> 1]

When creating a variable by indicating a new context in the form context`variable a new context will be created along with the variable. This can be verified using Contexts[]

  • @Karsten 7 thx for the formatting,,,,penguins not very smart :) – penguin77 Apr 8 '15 at 9:12

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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