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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:46:10+00:00 2026-05-30T17:46:10+00:00

Say I am running new CommentList().execute(url); If I am in the doInBackground method and

  • 0

Say I am running

new CommentList().execute(url);

If I am in the doInBackground method and I catch a Null value and inside that null value exception I try running the same one again:

new CommentList().execute(url);

Will it stop running the first one?

Can I do this:

if (result == null) {
    cancel(true);                           
    }

@Override
    protected void onCancelled() {
        new CommentList().execute(commentlinkurl);
    }

Basically I don’t want the onPostExecute to run if it gets cancelled.

  • 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-30T17:46:11+00:00Added an answer on May 30, 2026 at 5:46 pm

    This is not a good idea. You should not be creating new task on a non-UI thread (from within doInBackground method).

    From docs:

    There are a few threading rules that must be
    followed for this class to work properly:

    • The task instance must be created on the UI thread.
    • execute(Params…) must be invoked on the UI thread.
    • Do not call onPreExecute(), onPostExecute(Result), doInBackground(Params…), onProgressUpdate(Progress…) manually.
    • The task can be executed only once (an exception will be thrown if a second execution is attempted.)

    Edit based on comments:
    You can however start the task again inside onPostExecute or onCancelled method. You can simply return some specific result to it from doInBackground or save your Throwable in the AsyncTask member variable to analyze it further:

    protected void onPostExecute(Something something) {
        if(something == null){
            // safe to start new execute task here
        }
        // or
        if(mException instanceof TemporaryIssueException){
            // safe to start new execute task here
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm running a hosted service that wishes to allow plugins written by
Say I am running a PHP script, foo.php, inside apache configured with mod php,
I'm running a process from inside a windows service using: ProcessStartInfo processStartInfo = new
Lets say that we have a server running multiple virtual hosts. Somefiles and directories
I'm new to WCF. Let's say I have two asp.net apps, one that uses
Hello I keep running into errors and outputs that say undefined in my output
Hi there First of all just let me say that I'm new in Python
Say you have a legacy website running on an old code-base that offers certain
Let's say I'm running a simple server and have accept() ed a connection from
say a ruby script is running ruby.rb SOMEUSERID using PHP, how can i find

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.