Does somebody know a way execute a task via a script that doesn’t freeze LL while it’s being executed?

Does somebody know a way execute a task via a script that doesn’t freeze LL while it’s being executed? I’ve tried posting runnables on the view of a container, but it doesn’t help.

Thanks in advance 🙂

]]>

14 Commentsto Does somebody know a way execute a task via a script that doesn’t freeze LL while it’s being executed?

  1. Anonymous says:

    < ![CDATA[

    Tried that before runnables, also freezes LL

    ]]>

  2. Anonymous says:

    < ![CDATA[

    If you can split your task into several smaller, you can call subsequent setTimeout calls to prevent a freeze. Otherwise use Thread or AsyncTask.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    I just tried to do this, but I have to extend a Java class and override on of its methods and I don’t really know how to do that. This is wat I tried:


    LL.bindClass(“java.lang.Thread”)


    var TestThread = function(){


    this.run = function(){


    log(“test”)


    }


    }



    TestThread.prototype = Thread;



    var testThread = new TestThread()


    testThread.start()



    It can’t find the start method in Thread

    ]]>

  4. Anonymous says:

    < ![CDATA[

    LL.bindClass(“java.lang.Thread”);


    LL.bindClass(“java.lang.Runnable”);


    new Thread(new Runnable(){


    run:function(){



    }


    }).start();

    ]]>

  5. Anonymous says:

    < ![CDATA[

    that crashes LL for me…

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Colin de Roos


    then your function is not valid.

    ]]>

  7. Anonymous says:

    < ![CDATA[

    the function was it.setLabel(“test”) and “it” is directly pulled from the event that launches the script, which is a long tap on the item. If that’s not valid i don’t know what is

    ]]>

  8. Anonymous says:

    < ![CDATA[

    i did read something about that it’s bad for u to try to update a gui outside of the guithread, so maybe that’s the problem?

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Colin de Roos


    very likely yes.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Hmm, do you think it’s still worth trying with AsyncTask?

    ]]>

  11. Anonymous says:

    < ![CDATA[

    I confirm that Android UI is not designed to be accessed from several threads at once, and Lightning isn’t neither. Each time you need to change some UI related stuff, you need to do it on the UI thread. One way to do this is using a Handler created before to start the thread (that is: on the UI thread), and in the other thread use handler.post(new Runnable() { the code to execute});

    ]]>

  12. Anonymous says:

    < ![CDATA[

    yes i came up with that last night too. Gonna try that now.

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Seems to work! Thanks a lot guys!

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *