Re: *slowing down* a Mathematica process (Dynamic/Refresh question)
- To: mathgroup at smc.vnet.net
- Subject: [mg101151] Re: *slowing down* a Mathematica process (Dynamic/Refresh question)
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Thu, 25 Jun 2009 07:14:01 -0400 (EDT)
- References: <h1sv6e$mcj$1@smc.vnet.net>
Hi Michael,
Here is a slightly modified version of your code. I replaced your
outside source with Random[] to get some live 'data'. FinishDynamic
should only be necessary if you want to display all updates of high
frequency events.
The key here is to set TrackedSymbols to {} because every change in
holder causes an additional trigger event. I've added the variable c
that is incremented all the time to show that execution and display
occur with the same rate.
c = 1;
DynamicModule[{holder},
Dynamic[Refresh[{c++, holder = Random[]}, UpdateInterval -> 1,
TrackedSymbols -> {}]]]
To see why this works examine the following example in which holder
remains the same and :
c = 1;
DynamicModule[{holder},
Dynamic[Refresh[{c++, holder = 1}, UpdateInterval -> 1,
TrackedSymbols -> {holder}]]]
and here were
c = 1;
DynamicModule[{holder},
Dynamic[Refresh[{c++, holder = 1}, UpdateInterval -> 1,
TrackedSymbols -> {holder, c}]]]
BTW UpdateInterval->t only asks for an update MINIMALLY once every t
seconds (if possible). It does not force the update interval to be t
seconds.
Cheers -- Sjoerd
On Jun 24, 12:29 pm, Michael Stern <nycst... at gmail.com> wrote:
> I hope to use Mathematica as an interface to an outside process, in
> which it periodically polls an outside data source and performs
> calculations on the data. The problem is, the loop is quick and
> Mathematica polls the outside datasource too often. UpdateInterval does
> not help (I think it effects how often the updated results are
> displayed, but the polling continues as quickly as Mathematica can do
> it). Adding a call to Pause[] doesn't help either, as it causes the
> entire session to freeze and become unusable.
>
> I have tried this a variety of ways, getting the same behavior each
> time. A schematic of one version of the code appears below
>
> DynamicModule[{holder},
> Dynamic[Refresh[FinishDynamic[]; holder = callToOutsideDataFeed[],
> UpdateInterval -> 1]]
>
> Are there any Dynamic/Refresh gurus out there who can help?
>
> Thank you,
>
> Michael Stern