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

  • Home
  • SEARCH
  • 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 8831583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:20:33+00:00 2026-06-14T08:20:33+00:00

I have a function checkReg() which checks to see if my device has been

  • 0

I have a function checkReg() which checks to see if my device has been registered on a server the first tine it is launched and returns a regStatus variable. The function works fine but it takes a bit of time for the reg to complete and my application cannot proceed without confirming registration is done.

I would like to use a simple thread to check the regStatus once 1 sec and after 5 tries if it hasn’t been registered then kill the thread and go back, if it is done before 5 tries then kill the thread and proceed.

Thread(run every 1 sec){
    regStatus=checkReg();
    if(regStatus==='done'){

        //do something
        //kill thread
    }else if(regStatus==='inprogress'){

        //do nothing
    }elseif(regStatus==='error'){

        //kill thread
    }
}

I am quite new to JS and do not know how to start, time or kill the thread. I have used the setTimeout function but I’m not sure it can do what I want.

  • 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-06-14T08:20:34+00:00Added an answer on June 14, 2026 at 8:20 am

    JavaScript doesn’t have threads in general, but you can easily use setInterval() instead:

    var retry = 0
    
    function checkStatus() {
      var regStatus=checkReg();
      if(regStatus==='done'){
        //...
      }
      if(++retry > 5) {
        clearTimeout(id);
      }
    }
    
    var id = setInterval(checkStatus, 1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have function getMemory() which returns VARIANT (mfc). It is said that in ulVal
I have function that have been colled in stored procedure. The function returns a
i have function, which has to accept two types of data - Observable collection
I have function build_additional_docs which calls another function that do few actions, but first
I have function which checks the score and will(I haven't finished) increases level if
I have function some_func_1 which will create an object of type some_type and will
i have function to send mail with attachment to microsoft exchange server. My problem
Inside my Controller i have function that runs after user clicks on item, which
I have function that returns the index of a character GetCharFromPos(Pt: TPoint): Integer; now
I have function which takes in an parameter of a class called Triple, and

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.