finished = false; $this->result = null; $this->onRun(); $this->finished = true; } /** * @return bool */ public function isFinished(){ return $this->finished === true; } /** * @return mixed */ public function getResult(){ return unserialize($this->result); } /** * @return bool */ public function hasResult(){ return $this->result !== null; } /** * @param mixed $result */ public function setResult($result){ $this->result = serialize($result); } public function setTaskId($taskId){ $this->taskId = $taskId; } public function getTaskId(){ return $this->taskId; } /** * Actions to execute when run * * @return void */ public abstract function onRun(); /** * Actions to execute when completed (on main thread) * Implement this if you want to handle the data in your AsyncTask after it has been processed * * @param Server $server * * @return void */ public function onCompletion(Server $server){ } }