# How to stop a Dynamic[] in one notebook from hurting performance in another?

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
• 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[{clockd, clockh, clockm, clocks} =
List @@ DateDifference[Now,
DateObject[{2015, 5, 18}], {"Day", "Hour", "Minute",
"Second"}][[1]];

Grid[Transpose@{{"d", clockd}, {"h", clockh}, {"m", clockm}, {"s",
Round@clocks}}, Alignment -> Left], UpdateInterval -> 1]


When creating a variable by indicating a new context in the form contextvariable 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