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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:20:01+00:00 2026-06-05T01:20:01+00:00

Possible Duplicate: Execute an “if” condition “x” milliseconds and stop for “y”millisecond and repeat

  • 0

Possible Duplicate:
Execute an “if” condition “x” milliseconds and stop for “y”millisecond and repeat the condition ?

I have a program that test a condition inside a if loop continuously during the run of the programme. But i want this if condition to become true or active for certain period of time(say for 5ms) and then deactivate the if condition for next 10ms. Then continue this pattern continuously until user close the program!

  • 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-05T01:20:02+00:00Added an answer on June 5, 2026 at 1:20 am

    Although it sounds like you should really take a different approach, this is the answer to your question literally:

    while ( YES )
    {
        NSTimeInterval t = [NSDate timeIntervalSince1970];
        long ms = t*1000;
        if ( ms % 15 < 5 )
        {
           // code here is executed for 5 ms in every 15 ms timewindow
        }
    }
    

    This loop will be very detrimental to app performance and battery life.

    Depending on what kind of code has to be executed “for 5 ms, every 15 ms”, you could use an NSTimer instead:

    [NSTimer scheduledTimerWithTimeInterval:0.015 target:self
             selector:@selector(fire) userInfo:nil repeats:YES];
    

    with a method:

    -(void)fire
    {
        // called every 15 ms, does something for 5 ms.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What’s the “condition” in C interview question? void main() { if(CONDITION) printf(Hello
Possible Duplicate: Auto-open NERDTree in “EVERY” tab Is there a way to automatically execute
Possible Duplicate: Using global exception handling with “setUncaughtExceptionHandler” and “Toast” I have implemented UncaughtExceptionHandler
Possible Duplicate: Choose order to execute JUnit tests I am writing a JUnit test.
Possible Duplicate: How to execute a JavaScript function when I have its name as
Possible Duplicate: $(document).ready equivalent without jQuery I have a framework-less javascript that executes on
Possible Duplicate: Execute another jar in a java program Basically I want to run
Possible Duplicate: How to execute sql statements from a C program? I'm creating a
Possible Duplicate: MySQL number of items within “in clause” In mysql or postgres, is
Possible Duplicate: Running junit tests in parallel? I found the test cases inside jUnit

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.