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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:28:44+00:00 2026-06-11T19:28:44+00:00

The code is shown as below, I have a button once you click it

  • 0

The code is shown as below, I have a button once you click it activates timer and timer calls method every 4sec. However, sometimes 4 sec is not enough for server to return the data. However, increasing the timer value is not also good solution if server returns data in 1 sec and would not good for user to wait longer. I do not know what is best/optimal solution in this case.

-(IBAction)play:(id)sender{
    timer=[NSTimer scheculedWith TimerInterval(4.0) target:(self)selector:@selector(httpRequest) userinfo:nil repeats:YES]
    }
    -(void)httpRequest{

    _weak ASIHTTPRequest *request1 = [ASIHTTPRequest requestWithURL:url1];
    [request1 setCompletionBlock:^{
        NSString *responseString1 = [request1 responseString];
    //dispatch_async(backgroundProcess1,^(void){
        [self plotOverlay1:responseString1];
     //});
    }];
    [request1 setFailedBlock:^{
        NSError *error=[request1 error];
        NSLog(@"Error: %@", error.localizedDescription);
    }]; 

    [request1 startAsynchronous];
    }
  • 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-11T19:28:45+00:00Added an answer on June 11, 2026 at 7:28 pm

    If you just want the data to be updating continuously, consider calling -httpRequest again from within the completion block of the first request (and removing the timer). That way, you can be assured that the request will get performed again, but only after the first request finishes – and you can introduce a delay there, so you get something like “check again two seconds after the first check finishes.”

    This might look something like:

    - (void)httpRequest {
        __weak ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:url1];
        [req setCompletionBlock:^{
            NSString *resp = [req responseString];
            [self plotOverlay1:resp];
    
            [self httpRequest];
            // or...
            [self performSelector:@selector(httpRequest) withObject:nil afterDelay:2.0];
        }];
        /* snip fail block */
        [req startAsynchronous];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a YUI module a little like the code shown below, which
I have two OptionMenu widgets in the simple pieces of code shown below: variable
I have some code as shown below: - (IBAction)startButtonPressed:(id)sender { statusText.text = @Processing...; //here
I have a python psp page code is shown below. Currently it only prints
Currently I have a borderContainer layout as shown below: My code for this layout
Background: I have a WPF UserControl (MainControl - not shown in code below) that
I have written the code shown below. my problem is that I can't touch
I have the following code shown below in my program. One of the message
i have created xml file with the code shown below, XElement xml = new
I currently have a jQuery code for 4 buttons. Basically you click the button,

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.