Implemented Publish Progress in AsyncTask

Discussion in 'Contributing & RFCs' started by SOFe, Nov 11, 2016.

Tags:
  1. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,980
    GitHub:
    sof3
    PocketMine AsyncTask lacks support for publishing progress in an AsyncTask.

    ## What is progress publish?
    Refer to Android's AsyncTask API:
    > This method can be invoked from doInBackground(Params...) to publish updates on the UI thread while the background computation is still running. Each call to this method will trigger the execution of onProgressUpdate(Progress...) on the UI thread. onProgressUpdate(Progress...) will not be called if the task has been canceled.

    In simple words, the AsyncTask worker thread (the implementation of AsyncTask actually) can trigger a method called publishProgress. It will pass some primitive data (or Threaded objects) to the main thread. The main thread scheduler heartbeat will check for these calls (just like it checks to call onCompletion), and trigger a method onProgressUpdate on the AsyncTask from the main thread. Hence, with about half/one tick delay, an AsyncTask's progress can be published from the worker thread and correctly displayed to the main thread (hence sending messages to users, triggering server loggers, etc.).

    Example: (the steps refer to the 4 steps in the Android AsyncTask API)
     
    Last edited: Nov 16, 2016
    Awzaw likes this.
  2. PocketKiller

    PocketKiller Slime

    Messages:
    84
    GitHub:
    iPocket
    [Off-Topic] (Ah nu pls Intyre(no mention, no alert))This is BBCode, so why use HTML in <a>...
    Anyway, I think it's ready to merge.
     
  3. archie426

    archie426 Baby Zombie

    Messages:
    130
    GitHub:
    archie426
    What do you mean?
     
    Last edited: Dec 28, 2016
    Dog2puppy and HimbeersaftLP like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.