I want to make a Graphics
with a Disk
whose position should update every 4 seconds. This is what I've got so far:
RunScheduledTask[(cdts = RandomReal[{-5, 5}, 2]), 4]
{Framed[Graphics[{Yellow, Disk[Dynamic@cdts, 1]}, PlotRange -> 6,
ImageSize -> Large]], Dynamic@cdts}
I chose not to use Refresh
because that evaluates way more than once every 4 seconds (I'd say every half second or so), even though I've set UpdateInterval-> 4
, like so:
{Framed[Graphics[{Yellow,
Disk[Dynamic@Refresh[cdts, UpdateInterval -> 4], 1]},
PlotRange -> 6, ImageSize -> Large]], Dynamic@cdts}
From a previous question I asked, I think this is because Mathematica takes the UpdateInterval
as a minimum, and so updates much more often when it can.
From what I've read in the documentation, RunScheduledTask
should do exactly what I'm looking for, but it seems to update just as quickly as Refresh
, about twice a second.
What am I doing wrong here?? I've been looking for quite a while now for a straightforward method to periodically run functions but none of them seem to work as advertised...
RunScheduledTask
. Are you sure you do not have a couple of tasks running simultaneously? $\endgroup$cdts
is changed. Your observations are caused by not removing oldScheduledTasks
. $\endgroup$