Execute JS from within a thread


I want to Execute JS from within a thread. Is that possible?

The Idea behind:
I’ve got a huge Webapp, which sometime has to execute large methods where the users have to wait.

I’m searching for a solution to show, that the webapp works, f. e. with a progresswheel (PW).

While I can’t set the PW visible=true on start of a method and visible=false on the end, I thought I solve this with Javascript and a thread.
This is what I want to execute: document.getElementById("ControlID").style.visibility = "hidden/visible";

How could I execute JS within a thread?

all your web code runs on some thread. and if you call control.ExecuteJavascript it’s put on the control and send soon to the browser to run it.

ExecuteJavascript doesn’t get you anything. The commands are still sent to the browser all at once.

One way to do this is to create a subclass of WebThread and add a property to the thread, something like progressControl as WebControl. Set progressControl.visible=true right before you create the thread and progressControl.visible=False at the bottom of the Thread’s run event. Make sure you also set progressControl = nil. If you don’t do this last part, you’ll leak memory.