Asynchronous programming linearization operation

  ios, question

There is such a scene

A multi-step and time-consuming I/O operation is performed during App initialization.

I would like to ask you whether such an operation is event-driven (such as Handler in Android and NotificationCenter in iOS), or whether it is better to directly use callback functions.

Because there are many steps in this operation, after the first step is completed, start the second step, after the second step is completed, start the third step, and so on. Because it is an I/O operation, they should all be in asynchronous thread inside.

The way I use now is to start the next task in the callback of each step, but it feels strange to write this way. How does everyone do it?

This Android actually encapsulates an asynchronous class of Handler.
AsyncTask, you can do this step by step directly in doInBackground, and you can publishProgress one step at a time.

class MyTask extends AsyncTask<Void, Integer, Integer> {
 public void doInBackground(Void... params) {
 // step 1
 int resultCode = step1();
 if (resultCode == 0) {
 //   ...
 public void onCancelled() {
 //One step failed. Cancel
 public void onProgressUpdate(Integer... progress) {
 //Custom Phase