# Showing updating message in Dynamic with UpdateInterval

I am creating an interface which needs to repeat an operation every few seconds. The operation itself is expensive but faster than the update interval of the interface.

I would like to have some visual feedback to know every time the operation starts and ends but I have not been able to find a solution that works well.

This is what I have now:

expensive[k_] := (Pause[2]; k + 1)

DynamicModule[{k = 0, status = "not calculating"},
{
Dynamic[
Refresh[status = "calculating";
k = expensive[k];
status = "not calculating",
UpdateInterval -> 5, TrackedSymbols :> {}]],

Dynamic[{status, k}, TrackedSymbols :> {status}]
}
]


Does anyone know how why it is not working and how to fix it?

This question is related to Showing "updating..." message while Manipulate is re-evaluating but the refresh is triggered by an UpdateInterval instead of a button.

Each Dynamic is using preemptive link and it is theoretically possible to do what you need. However, there are no tools to manage evaluation precisely (one could try with FinishDynamic[]). At the moment you are using one link which is busy so it can't update second Dynamic.

You can't count on specific order of tasks but you can send one to main link by using SynchronousUpdating -> False:

expensive[k_] := (Pause[2]; k + 1)

DynamicModule[{k = 0, status = "not calculating"},
{Dynamic[
Refresh[
status = "calculating";
k = expensive[k];
status = "not calculating"
,
UpdateInterval -> 5,
TrackedSymbols :> {}
]
,
SynchronousUpdating -> False
],
Dynamic[{status, k}, TrackedSymbols :> {status}]}
]


p.s. are you sure you don't want to use ScheduledTasks?

• Thank you Kuba. This works! For now I manage evaluation just with a UpdateInterval->If[autoUpdate, 5, Infinity]. Maybe down the road I switch to a ScheduledTask, but I generally try to avoid those. I once tried to use it for a once per day task and it was not reliable at all. Maybe for tasks with a shorter period it works better. – Gustavo Delfino Nov 16 '15 at 19:36