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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:31:49+00:00 2026-05-27T21:31:49+00:00

I have a long running io process that I would like to be able

  • 0

I have a long running io process that I would like to be able to set a progress bar during to show that there is in fact a process running and the app isn’t just frozen. The process copies over many music files, and can take upwards of a minute depending on how many are available.

The problem is, it seems to be executing the code before setting the progress bar visibility.

    public void makeAvailable() {
    mProgressBar.setVisibility(View.VISIBLE);
        File dir = new File(gMusic);
        String[] songNames = dir.list();
        File[] songs = dir.listFiles();
        for (int i=0; i<songs.length; i++) {
            File song = songs[i];
            String songName = songNames[i];
            String[] bits = songName.split("/");
            String songStripped = bits[bits.length-1];
            File output = new File(Constants.gMusicSniperDir + "music/" + songStripped);
            try {
                copyFile(song, output);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        mProgressBar.setVisibility(View.INVISIBLE);
}

As you see, it cycles through the directory and copies all the files over. When it runs, the only indication of anything happening is that the button that is tied to the process doesn’t leave the “pressed” state – it stays highlighted blue.

  • 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-27T21:31:49+00:00Added an answer on May 27, 2026 at 9:31 pm

    It looks like you’re doing all your work in the UI thread. You should do all the heavy work (listing the contents of the directory, and copying files) in a background thread, posting requests to the UI thread just to update the progress bar.

    The ProgressBar documentation gives an example of this.

    Note that this is just one example of a common theme: you shouldn’t block the UI thread for any significant length of time, or your application will become unresponsive. See “Designing for Responsiveness” for more details.

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

Sidebar

Related Questions

I have a long-running Python server and would like to be able to upgrade
I have a long running process in VB6 that I want to finish before
I have several long running report type transactions that take 5-10 minutes. Would I
As recommended here I would like to have an external processes running that listens
I have a long running process called ImportProductInformation called by a consoleapp that I'm
I have a long running process and I need it to launch another process
I have an application for PDAs with a long running process, and I'm getting
I have a situation where user requests to do a long running process. I
I have a long running SQL statement that I want to run, and no
I have a long running insert transaction that inserts data into several related tables.

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.