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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:39:06+00:00 2026-05-22T15:39:06+00:00

Imagine I have a spinner that I have to enable while something relatively heavy

  • 0

Imagine I have a spinner that I have to enable while something relatively heavy is being done and then deactivate the spinner after the task is done.

If I do:

[mySpinner startAnimating];
[self doSomethingHeavy];
[mySpinner stopAnimating];

I will never see the spinner running, because doSomethingHeavy will lock the thread and never let the spinner show.

I have tried to fire a new queue on the main thread using Grand Central Dispatch for the spinner and in another try for the task, but the results are the same. No spinner running.

The only way to make it work is to fire the method with a delay, using

[self performSelector:@selector(doSomethingHeavy) withObject:nil afterDelay:0.02];

but this sounds more like a hack and if I put [mySpinner stopAnimating] after that line, it will probably stop the spinner before the task is done.

This is not just valid for the spinner but for any task that that needs screen update.

  • 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-22T15:39:07+00:00Added an answer on May 22, 2026 at 3:39 pm

    I have tried these solutions but unfortunately none worked, because my doSomethingHeavy method must be run on the main thread too.

    Using the hack of firing the method with a delay works but not for methods that should run with more than one parameter, as performSelector: afterDelay: cannot be used to pass more than one parameter.

    I found a solution firing a queue on the main thread using Grand Central Dispatch and then sleeping it for 0.02 seconds. Using the queue, I can put anything I want.

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

Sidebar

Related Questions

Imagine I have the folling XML file: <a>before<b>middle</b>after</a> I want to convert it into
Imagine I have a process that starts several child processes. The parent needs to
Imagine I have the following: inFile = /adda/adas/sdas/hello.txt # that instruction give me hello.txt
Imagine I have the coordinate of 4 points that form a polygon. These points
Imagine you have 100 tweens. Each tween is simply an element (circle) that goes
Imagine you have a database table that stores a list of people. You want
Imagine I have the following code that runs as a background processor for an
Imagine I have the following string : set(SEXY_STRING I love CMake) then I want
Imagine I have a table called item that has a column called price. In
Imagine I have something like this: def example = { def temp = ConferenceUser.findAllByUser(User.get(session.user))

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.