Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

evaluation of a non-visible dynamic[]

22 views
Skip to first unread message

AlexG

unread,
Oct 16, 2010, 1:20:54 PM10/16/10
to
Does anybody know?

I like the way dynamic works asynchronously with the rest of my code.
The problem is, it only works when the output of the dynamic[]
function call is visible on the screen. Is there some way I can
programmatically tell dynamic when start and stop updating? If there
is, I will be VERY happy!

Much Appreciation,
--Alex Gurfinkel

John Fultz

unread,
Oct 18, 2010, 5:59:32 AM10/18/10
to

Some people have asked for Dynamics that don't require being displayed.
The problem with this is alluded to by your question...if such a
thing existed, then you would have to invent some form of lifetime
management...i.e., ways to start, stop, and kill it. Otherwise, once
the Dynamic was evaluated, it would just sit there, soaking up resources
and potentially evaluating again and again, for as long as the kernel
is alive.

I don't have a precise answer for what you say you're looking for. But
I'll discuss some conceptually similar things you may find interesting.

Dynamics can be stored in the front end options CellDynamicExpression,
NotebookDynamicExpression, and FrontEndDynamicExpression. These Dynamics
are not displayed, but are updated when the cell/notebook/frontend to
which they are attached is displayed. That is, there's no guarantee that
they will evaluate if, for example, the owning notebook is minimized or
is set to Visible->False.

In the soon-to-be-released version 8, which was publicly revealed
at Mathematica User's Conference last week, there is a feature called
ScheduledTasks which may be what you're looking for. They're background
tasks which are run at intervals. If you really need the dependency
mechanism, then that probably won't help you, but if you're just
looking for periodic background tasks, then you probably will find it
quite useful.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.

Michael

unread,
Oct 19, 2010, 5:58:23 AM10/19/10
to
On 10/18/2010 2:58 AM, John Fultz wrote:
> On Sat, 16 Oct 2010 13:11:16 -0400 (EDT), AlexG wrote:
>> Does anybody know?
>>
>> I like the way dynamic works asynchronously with the rest of my code.
>> The problem is, it only works when the output of the dynamic[]
>> function call is visible on the screen. Is there some way I can
>> programmatically tell dynamic when start and stop updating? If there
>> is, I will be VERY happy!
>>
>> Much Appreciation,
>> --Alex Gurfinkel
>
> Some people have asked for Dynamics that don't require being displayed.
> The problem with this is alluded to by your question...if such a
> thing existed, then you would have to invent some form of lifetime
> management...i.e., ways to start, stop, and kill it. Otherwise, once
> the Dynamic was evaluated, it would just sit there, soaking up resources
> and potentially evaluating again and again, for as long as the kernel
> is alive.

Along this line, what I think would be very useful is something similar
to a spreadsheet-like dependency tracking. I've set up something like a
spreadsheet, using delayed assignments as formulas and using Table,
Dynamic and InputField, and it works. The problem is, if multiple cells
depend on a single formula it gets recalculated once for each time it is
used. For a large spreadsheet this can result in a great deal of
recursive re-calculation which is not necessary. (And sometimes
Mathematica crashes; I think this is an unrelated InputField bug, but I
gave up on tracking it down...) I wanted to try memoizing the results of
each cell, but I realized that I don't have any way of knowing when the
current re-calculation set is over (or about to begin).

In a calculation there is a variable I can look at to tell if a dynamic
expression is currently being evaluated. If Mathematica could provide a
hook that it calls when calculation starts and/or ends that would be a
way that I could determine when to flush my memoized results. I would
imagine the start hook would be called any time user input results in
new calculations being sent to the kernel, and the end hook would be
called when the last result is received back from the kernel.

> Sincerely,
>
> John Fultz
> jfu...@wolfram.com
> User Interface Group
> Wolfram Research, Inc.


Best Regards,

Michael

0 new messages