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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:38:39+00:00 2026-06-05T03:38:39+00:00

Before I’m lampooned, for blocking the main UI thread, here is the scenario: A

  • 0

Before I’m lampooned, for blocking the main UI thread, here is the scenario:

  1. A Service runs once a day – takes around 15 secs to complete. Heavy database transactions
  2. By coincidence the user starts the app during that time
  3. The home screen loads data from the database
  4. But because the database is locked (step 1), this throws an error.

So I need to FREEZE the UI thread till the service is completed. No AsyncTask because the UI will continue to execute and throw an error. I’ve managed to put the “onResume” function to sleep till the service finishes. But during that time I’m unable to show any dialogs telling the user to wait or any progress bar telling the user to sit tight.

If I try

start onResume

if (service is running?)
    show progress dialog
    while the service is running, thread.sleep
    dismiss progress dialog

end onResume

The thread sleeps fine and wakes up great. But the damn progress dialog doesn’t show till onResume…resumes! Bottom line, how do I show an indicator (progressdialog or dialog) before I put the main thread to sleep?

I’m open to solutions that load another activity till the service resumes. I’ve tried that, but the previous activity continues on happily 😐

  • 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-05T03:38:41+00:00Added an answer on June 5, 2026 at 3:38 am

    You can not show a progress dialog if you are blocking the UI thread.

    I guess you want to invoke the dialogue in onResume, but the UI won’t start to show the dialog before onResume and onPaused are done. But as you are blocking the UI thread in OnResume this will not be reached until the blocking is over. Therefor its not possible.

    You need to put the waiting in an async task and callback to your UI thread when done.
    Good would be to take a loading-activity that starts your actual activity when the DB update is finished.

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

Sidebar

Related Questions

Before all: excuse my english :) Ok, here we go - im developing mostly
Before a thread locks a mutex, I want to check whether it has already
Before I get to my question/problem, here is the basic structure of my application:
Before a thread can wait on an object, it has to acquire a monitor
Before Django 1.0 there was an easy way to get the admin url of
Before answering, it is not as easy question as you might have thought about
Before you start flaming, I'm going to tell you that I am trying to
Before I roll my own Queue using NSMutableArray , I'd like to know if
Before I begin I'll freely admit it's something in my code but it's not
Before I throw something ugly together I thought this would be a good one

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.