I wanted to know what is the REAL utility and all possibilities we can do with the AsyncTask, and how to use it correctly ? Thanks !
there's also an analogy there https://github.com/SOF3/forums-comm...ment-FAQ#asynctask-an-analogy-of-a-restaurant assuming you didnt read the full thing
And nobody can help you if you don't point out which part of it you don't understand. Otherwise all that we can tell you is the same thing.
For how to construct an AsyncTask, it is a question of PHP knowledge, which is not related to this forum. Look at the PHP documentation if you need help with constructing objects in PHP. For the difference between onRun and onCompletion, onRun() is the bulk operation (cooking the food) that should be executed in worker threads, while onCompletion() is the operation executed in the main thread that handles the result of the bulk operation (serving the food to the customer).
Actually, I know what this is can do now, but to construct, it still hard for me. onRun() -> Just PHP, not PM API onCompletion() -> PM API can be used
Define "PM API" well. In fact, a lot of the PocketMine API do not reference the Server god object and can be used freely. Methods in AsyncTask, e.g. publishProgress(), setResult(), can still be used.