How make a AsyncTask

Discussion in 'Development' started by Draglor56, Oct 11, 2020.

  1. Draglor56

    Draglor56 Silverfish

    Messages:
    24
    Hello, I have a question. I want to make a AsyncTask, but I don't know how to make it and how to call it in the Main Class. Can someone show me how?
     
  2. EndermannbugZJFC

    EndermannbugZJFC Witch

    Messages:
    53
    GitHub:
    endermanbugzjfc
    PHP:
    class AsyncTaskExample extends \pocketmine\scheduler\AsyncTask {
      public function 
    __construct() {
        
    $this->storeLocal(mixed complex data to store);
      }
      public function 
    onRun() : void {
        
    $this->publishProgress(progress);
        
    $this->setResult(result);
      }
      public function 
    onCompletion(\pocketmine\Server $server) : void {
        
    $this->getResult();
        
    $this->fetchLocal();
      }
      public function 
    onProgressUpdate(\pocketmine\Server $server$progress) : void {
        
    $this->fetchLocal();
      }
    }
    PHP:
    $this->getServer()->getAsyncPool()->submitTask(async task instance);
     

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.