Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 341a205

Browse files
codePushNativeModule: launch async tasks in parallel (#693)
AsyncTasks are executed on a single thread to avoid common application errors caused by parallel execution. So to make it possible to use tools like AsyncStorage while CodePush downloading an update we should use `asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);` code instead of `asyncTask.execute()`
1 parent 4df7235 commit 341a205

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public void dispatchDownloadProgressEvent() {
290290
}
291291
};
292292

293-
asyncTask.execute();
293+
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
294294
}
295295

296296
@ReactMethod
@@ -364,7 +364,7 @@ protected Void doInBackground(Void... params) {
364364
}
365365
};
366366

367-
asyncTask.execute();
367+
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
368368
}
369369

370370
@ReactMethod
@@ -416,7 +416,7 @@ protected Void doInBackground(Void... params) {
416416
}
417417
};
418418

419-
asyncTask.execute();
419+
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
420420
}
421421

422422
@ReactMethod
@@ -485,7 +485,7 @@ public void onHostDestroy() {
485485
}
486486
};
487487

488-
asyncTask.execute();
488+
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
489489
}
490490

491491
@ReactMethod

0 commit comments

Comments
 (0)