Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6380205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:14:17+00:00 2026-05-25T02:14:17+00:00

I am trying to see if I can make my own simulation loop inside

  • 0

I am trying to see if I can make my own simulation loop inside Manipulate as I am not happy with either the Trigger control or using Tasks (both have problems and limitations for what I’d like to do).

So, I was trying to see if I can make my own control loop, this way I have better control of things, where by clicking on a ‘run’ button, simulation loop will start until a ‘stop’ button is clicked.

A basic problem is that Manipulate times out after 5 seconds even though I am using SynchronousUpdating -> False. i.e. when I click the ‘run’ button, I start a loop (with some Pause[] in it of course), and will then update something in the loop. This works fine, but after 5 seconds, the loop stops on its own, since Manipulate decided to time out.

I might be misunderstanding something basic here. I show below simple example:

Manipulate[
Dynamic[Refresh[Text@x,TrackedSymbols->{x}]],

{{x,0},ControlType->None},
{{running,True},ControlType->None},

Button[Text["play"],
  {
   running=True,
   While[running,
     x+=1;
     FinishDynamic[];
     Pause[0.1]
   ]
  }],

Button[Text["stop"],
    running=False
  ],

TrackedSymbols->{None},
SynchronousUpdating->False,
SynchronousInitialization->False
]

When running the above, it always stops around count 58 or so, which is about 5 seconds, the time-out value for Manipulate

enter image description here

Outside Manipulate, it works ok as expected:

x = 0;
Dynamic[Refresh[x, UpdateInterval -> 0.001]]

Do[
 (
  x += 1;
  FinishDynamic[];
  Print[x];
  Pause[0.01]
  ), {i, 0, 200}
 ]

I can make the count above as large as I want, no problem.

So, it seems a configuration option for Manipulate, but I am now not able to find now which option it is I need to use for this to work.

Thanks

Update

Using the Method->”Queued” as given below by Simon, now the loop works. But there are problems with this method: I can not use Mathematica while the Button is running, even with large Pauses in the loop, as it blocks the whole front end. It behaves as if the button is pressed all the time. So, this idea is out of question to use. Well, it was something to try.

btw, this is a good time to mention this, I found that using cell of type ‘code’ instead of the default ‘input’ causes many crashes in the kernel. Just tried cell type ‘code’ and after few clicks on the button, kernel crashed:

enter image description here

So I no longer use cells of type ‘code’.

Back to the drawing board.

Update 2: 8/29/11, 6 PM

Using Mathematica 8.0.1, on windows 7, SP1, intel pc, here is the code that crashes it when using “code” cell

Manipulate[
Dynamic[Refresh[Text@x,TrackedSymbols->{x},UpdateInterval->0.005]],

{{x,0},ControlType->None},
{{running,True},ControlType->None},

Button[Text["play"],
  {
   running=True,
   While[running,
     x+=1;
     FinishDynamic[];
   ]
  },Method->"Queued"],

Button[Text["stop"],
    running=False
  ],

TrackedSymbols->{None},
SynchronousUpdating->False,
SynchronousInitialization->False
]

May be someone can try the above? Had to click on start/stop few times to get it to crash.

I can reproduce this.

enter image description here

Update 9/2/11

on new answer: It looks Simon version (second one below) seems faster on my PC, Mathematica 8.0.1. I started both at the same time, and the Simon version seems to run faster (counter runs faster).

screen shot:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:14:17+00:00Added an answer on May 25, 2026 at 2:14 am

    I think that it’s actually the Button that is timing out, not the Manipulate.

    To quote the Options > Method section of the Button docs,

    By default, button functions are evaluated on a preemptive link, which
    times out after 5 seconds:

    Set the option Method -> "Queued" for the button and everything works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't seem to figure this out, see code below. Trying to make a GET
Trying not to lose it here. As you can see below I have assigned
I am trying to create 100 files using FileOutputStream/BufferedOutputStream. I can see the CPU
I am trying to see if the performance of both can be compared based
I am trying to see which button was clicked on so I can preform
For fun I am trying to see how far I can get at implementing
Im trying to use this page slider jquery plugin, you can see the demo
I'm trying to secure an application so that users can only see objects which
Trying to convert the following but am having difficulty. Can anyone see where I'm
I'm trying to show thumbnail images in Django admin, but I can only see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.