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 3426384
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:42:33+00:00 2026-05-18T06:42:33+00:00

I need to let a piece of code always run independently of other code.

  • 0

I need to let a piece of code always run independently of other code. Is there a way of creating a thread in javascript to run this function?

–why setTimeout doesn’t worked for me

I tried it, but it runs just a single time. And if I call the function recursively it throws the error “too much recursion” after some time. I need it running every 100 milis (it’s a communication with a embedded system).

–as you ask, here goes some code

function update(v2) {
     // I removed the use of v2 here for simplicity
     dump("update\n"); // this will just print the string
     setTimeout(new function() { update(v2); }, 100); // this try doesn't work
}
update(this.v);

It throws “too much recursion”.

  • 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-18T06:42:34+00:00Added an answer on May 18, 2026 at 6:42 am

    Get rid of the new keyword for the function you’re passing to setTimeout(), and it should work.

    function update(v2) {
     try {
         dump("update\n");
     } catch(err) {
         dump("Fail to update " + err + "\n");
     }
     setTimeout(function() { update(v2); }, 100);
    }
    update(this.v);
    

    Or just use setInterval().

    function update(v2) {
     try {
         dump("update\n");
     } catch(err) {
         dump("Fail to update " + err + "\n");
     }
    }
    var this_v = this.v;
    setInterval(function() {update(this_v);}, 100);
    

    EDIT: Referenced this.v in a variable since I don’t know what the value of this is in your application.

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

Sidebar

Related Questions

Ok, this piece of code may seem strange, but it's the only way I
Is there any Visual Studio tool that let's you run C# code without having
I need to let an aspx.cs file run code to enumerate the contents of
Let's look at the following piece of code which I unintentionally wrote: void test
I have this piece of code that I would like to shorten... PackageManager p
Please take a look at this piece of code I came up with. abstract
I've got a bad smell in my code. Perhaps I just need to let
Can anyone please explain to me whats wrong with this piece of code and
I need to execute a piece of code ONCE every first day of the
I have this piece of code on a php page, at the bottom: window.opener.location.href=/index.html;

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.