You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/01/03 21:22:59 UTC
[26/28] git commit: Spawn a thread when calling executeScript.
Spawn a thread when calling executeScript.
Create a new thread when calling executeScript to prevent native
side waiting on JavaScript call back to return.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/f1326c3f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/f1326c3f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/f1326c3f
Branch: refs/heads/master
Commit: f1326c3fe296dd86632bae4c29bc0094ab960a63
Parents: 8caf619
Author: Drew Walters <de...@gmail.com>
Authored: Sat Oct 29 02:10:55 2011 +0800
Committer: Drew Walters <de...@gmail.com>
Committed: Sat Oct 29 02:28:57 2011 +0800
----------------------------------------------------------------------
.../ext/src/com/phonegap/PhoneGapExtension.java | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/f1326c3f/framework/ext/src/com/phonegap/PhoneGapExtension.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/com/phonegap/PhoneGapExtension.java b/framework/ext/src/com/phonegap/PhoneGapExtension.java
index 03a994f..5384bf1 100644
--- a/framework/ext/src/com/phonegap/PhoneGapExtension.java
+++ b/framework/ext/src/com/phonegap/PhoneGapExtension.java
@@ -119,9 +119,16 @@ public final class PhoneGapExtension implements WidgetExtension {
// TODO Auto-generated method stub
}
- public static void invokeScript(String js) {
- script.executeScript(js, null);
- }
+ public static void invokeScript(final String js) {
+ // Use a new thread so that JavaScript is invoked asynchronously.
+ // Otherwise executeScript doesn't return until JavaScript call back
+ // is finished.
+ (new Thread() {
+ public void run() {
+ script.executeScript(js, null);
+ }
+ }).start();
+ }
/**
* Invokes the PhoneGap success callback specified by callbackId.