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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:24:29+00:00 2026-06-10T12:24:29+00:00

I am looking for a better way to do this, if possible. I have

  • 0

I am looking for a better way to do this, if possible.

I have an asynchronous callback that updates a local sqlite database. I set a flag in a singleton variable (archiveUpdateComplete) when the update completes. I sleep in a do-while until the flag gets set to true, then I hydrate my tableview. Would like to remove sleep()! Thanks for any suggestions.

#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)




- (void)viewDidLoad
{



  dispatch_async(kBgQueue, ^{

    //Hydrate word archive table view

       do {
             sleep(1.0);


           } while ([sharedManager archiveUpdateComplete]==NO);



      [self performSelectorOnMainThread:@selector(hydrateWordArchive) withObject:nil waitUntilDone:YES];


      //Run custom activity indicator
      dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:self.view animated:YES];

      });



  });

}
  • 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-10T12:24:31+00:00Added an answer on June 10, 2026 at 12:24 pm

    If you need to poll

    Polling/sleeping is rarely necessary or good. As an alternative:

    • You can attach an NSTimer to the main thread’s run loop.
    • The selector the timer calls can test [sharedManager archiveUpdateComplete]
    • if YES is returned, then
      • invalidate the timer
      • call [MBProgressHUD hideHUDForView:self.view animated:YES];

    If you don’t need to poll

    There are a few immediate alternatives. Which you choose depends on what knows about what:

    • If your manager knows who to message following completion, then the manager can simply message it. If that must occur on the main thread you can use -[NSObject performSelectorOnMainThread:withObject:waitUntilDone:] to forward to the main thread. You may also see this approach with delegates. In the case of a singleton, it doesn’t make a lot of sense to take this route.

    • If your manager does not know who is interested in the change/completion, your manager can post a NSNotification after the task has finished (on the current thread or from the main thread).

    • Key Value Observing (KVO) is another option.

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

Sidebar

Related Questions

Is there any better way to make this query work? I'm looking for a
Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database
Is there a better way to achieve this same result? I have a list
I'm looking for a better way, if it's possible, for manipulating an existing mondodb
I am looking to provide a better way of managing the distribution and storage
I was looking for a better mechanism for notifying my desktop clients that a
Alex explained what I'm looking for much better than I have: You want an
In asking this question, I'm looking for either better understanding of the situation or
I'm looking for a framework that is better and easier to use than Apache
Story I have a select control that represents user access level. I'm looking for

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.