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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:20:38+00:00 2026-06-01T16:20:38+00:00

I have some work to do in the another thread (by doingAsyncTask). Work start

  • 0

I have some work to do in the another thread (by doingAsyncTask).
Work start when user click on button. But at the same time
only one object of doingAsyncTask must do this work, i meen if doingAsyncTask is working, then click on button must not create a new object of doingAsyncTask and execute it, it must wait until work finish. How can i check it?

public class SearchActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //....
    }

    public void onclickButton(View view) {
        new doingAsyncTask().execute();
    }

    public class doingAsyncTask extends AsyncTask<Void, Void, Void> {
    protected Void doInBackground(Void... unused) {
        //doing something
        return(null);
    }

    protected void onProgressUpdate() {
    }
    protected void onPreExecute() {
    }
    protected void onPostExecute() {
    }
   }
}

SOLVED
thx all , its works for me

      if(task.getStatus() == AsyncTask.Status.FINISHED)
            task=new ProgressBarShow();
        if(task.getStatus() == AsyncTask.Status.PENDING){
            //task=new ProgressBarShow();
            task.execute();
        }
  • 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-01T16:20:39+00:00Added an answer on June 1, 2026 at 4:20 pm

    Check this AsyncTask.Status

    AsyncTask.Status    FINISHED    Indicates that onPostExecute(Result) has finished. 
    AsyncTask.Status    PENDING     Indicates that the task has not been executed yet. 
    AsyncTask.Status    RUNNING     Indicates that the task is running. 
    

    code:

    if (doingAsyncTask().getStatus().equals(AsyncTask.Status.FINISHED))
         doingAsyncTask().execute();
    else
    

    EDIT:

    public class SearchActivity extends Activity {
        doingAsyncTask asyncTask; 
    
        public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);             
           // ...
           asyncTask = new doingAsyncTask();   
        }
        public void onclickButton(View view) {
             if(ayncTask.getStatus().equals(AsyncTask.Status.FINISHED) || ayncTask.getStatus().equals(AsyncTask.Status.PENDING)) {
                 asyncTask.execute();
             }
             else {
                 // do something
             }
        }
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I spawn a thread (only one) to do some work and it pretty much
I'm onto problem 245 now but have hit some problems. I've done some work
I have some tabs using jQuery UI which work just fine, but I want
I have some elements I want to display. But sadly it does not work
I call obackgroundworker.CancelAsync(); on a background worker currently doing some work in another thread
I'm working on Android UI Thread, and there is one time-consuming work, so I
I have app that uses two threads: one thread for regular application work and
I have a two-thread application: GUI, and some background work. I'm trying to send
I have some experience in ASP.Net and can work my way around it without
I have some CSS style that does not work in IE and that works

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.