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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:23+00:00 2026-05-26T16:20:23+00:00

Sorry, the title is a bit hard to understand but I’m not 100% sure

  • 0

Sorry, the title is a bit hard to understand but I’m not 100% sure as to what to ask. its easier to show you the code and see if you understand from that. I found the way to use the progress dialog from another post on here, so this is basically adding onto that post. ( ProgressDialog not showing until after function finishes )
btw, this is using eclipse environment with the android plugin.

            final MyClass mc = new MyClass(text,info, this);
            final ProgressDialog dialog = ProgressDialog.show(this, "", "Loading. Please wait...", true);

            Thread t = new Thread(new Runnable() 
            {            
                public void run() 
                {
                    // keep sure that this operations
                    // are thread-safe!
                    Looper.prepare(); //I had to include this to prevent force close error

                    mc.doStuff();//does ALOT of stuff and takes about 30 seconds to complete... which is why i want it in a seperate thread

                    runOnUiThread(new Runnable() 
                    {                    
                        @Override
                        public void run() {
                            if(dialog.isShowing())
                                dialog.dismiss();

                        }
                    });
                }
            });
            t.start();

            tmp = mc.getStuff();

now the issue is that tmp is always null because mc isnt finished doing stuff. So, if i do this it finishes doing stuff, but doesnt show the progress dialog..

            t.start();
            while(t.isAlive());//noop
            tmp = mc.getStuff();

Any thoughts or ideas would be greatly appreciated!

  • 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-26T16:20:24+00:00Added an answer on May 26, 2026 at 4:20 pm

    In your second attempt, you are making the main thread wait for the new thread to complete.

    The runnable in the runOnUiThread call is where you want to do tmp = mc.getStuff();
    That will then be executed on the main thread after mc has finished doStuff().

    But otherwise, check out the link blindstuff commented, it simplifies threading.

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

Sidebar

Related Questions

Sorry, it's a bit hard to explain my question in a title, but basically,
Sorry for the title.....bit difficult to word what I really want to ask. Some
Sorry about the title, not sure how to describe without example. I trying to
Sorry if the title is a bit unclear/ambiguous but I am unsure of how
Sorry if title is not too clear but I think it's about right. NEhow,
Sorry my title is a bit vague, but what I'm trying to do will
Sorry if the title is not clear. I am a bit confused about how
Hi guys sorry for the awkward title but I think it is a bit
I m really sorry for unclear question title but I am a bit confused
I'm sorry if the title is a bit confusing, but this is my problem:

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.