Web Analytics Made Easy -
StatCounter Wait for asynctask to finish - CodingForum

Announcement

Collapse
No announcement yet.

Wait for asynctask to finish

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wait for asynctask to finish

    Hi
    I´m currently using AsyncTask to show a progressdialog while performing a background operation in android.

    When AsyncTask is finished, I want to use the result and then call a gui-control-method, but I dont want to call the gui-method in Asynctask (not in onPostExceute) because I want to seperate the model from view.

    I want to have a controller-class-method like this:

    Code:
    public void load(String input)
    {
         model.getAvailableAddressList(input);     -->  calling AsyncTask
    
         if (model.gotListSuccessfully())
               view.set(model.getList())   
    }

    Can this be done?

  • #2
    I'm not quite sure what you're question is.
    As soon as you called the getAvailableAddressList, the control is passed to the model method. It will not continue to process in load until the method is complete in the getAvailableAddressList. Once this method has completed, it will continue with the gotListSuccessfully block.
    If you're intent is to process data in the meantime, you can create a threaded task for this, and continually poll the getListSuccessfully to see if its complete. Once done, you would then execute the set of the view and update it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment

    Working...
    X