1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

AsyncTask onCompletion() result

Discussion in 'Development' started by Levi, Feb 17, 2019.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Players' balances are stored in a database. I run an async task to get someone's balance. I can do
    PHP:
    player->sendMessage(result)
    to send a message to the sender including their balance on
    PHP:
    onCompletion()
    .

    I need the result to return when the task is done. How do I do that?
     
    Last edited: Feb 18, 2019
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    PHP:
    $this->setResult($val);

    $this->getResult();
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Does not work. I do not see why it would.
     
  4. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you're trying to return the result to another file? just call a function on the onCompletion method and put $this->getResult() as the first parameter
     
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    I did and it is giving me 0(zero), which is wrong because when I sent message to me in onCompletion() it gives me the right number from the database
     
    Last edited: Feb 19, 2019
  6. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    I don't understand what you're saying
     
  7. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    setResult in onRun and getResult in onCompletion
     
  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.