Procedure freezes open window
Procedure freezes open window
Hey all,
Some of the procedures in my program can take a very long time to return. Is it possible to thread a procedure? Or to let it run in the background while the open window is still responsive?
Thanks.
Some of the procedures in my program can take a very long time to return. Is it possible to thread a procedure? Or to let it run in the background while the open window is still responsive?
Thanks.
-
- Posts: 222
- Joined: Sat Mar 01, 2014 3:02 pm
Re: Procedure freezes open window
You could take a look at Web Workers
Re: Procedure freezes open window
Thanks the.weavster for the link.
Is there no way to do this in SpiderBasic?
Is there no way to do this in SpiderBasic?
Re: Procedure freezes open window
currently you cannot do this with the native SpiderBasic commands.Jarlve wrote:Is there no way to do this in SpiderBasic?
But if you have a web server that can run your own cgi programs, then there is the possibility to use SpiderBite.
Greetings ... Peter
Re: Procedure freezes open window
Thanks Peter.
This should be possible out of the box.
Will use AddWindowTimer to let my procedure run periodically.
This should be possible out of the box.
Will use AddWindowTimer to let my procedure run periodically.
-
- Posts: 222
- Joined: Sat Mar 01, 2014 3:02 pm
Re: Procedure freezes open window
I haven't tried it but it seems to me it should only be a matter of putting some JavaScript code in an EnableJS .. DisableJS block (which can be within a SB procedure).Jarlve wrote:Is there no way to do this in SpiderBasic?
Edit...
The worker file itself would probably have to be in JS.
Re: Procedure freezes open window
yes, and that is the main problem.the.weavster wrote:Edit...
The worker file itself would probably have to be in JS.
You would have to write a Postprocessor that cuts the corresponding Procedure from the generated js-file after compiling by SpiderBasic and saves it as a separate WebWorker file.
Greetings ... Peter
-
- Posts: 222
- Joined: Sat Mar 01, 2014 3:02 pm
Re: Procedure freezes open window
Hi Peter
worker.js
worker.sb
But the WebWorker file is already separate:Peter wrote:You would have to write a Postprocessor that cuts the corresponding Procedure from the generated js-file after compiling by SpiderBasic and saves it as a separate WebWorker file.
worker.js
Code: Select all
onmessage = function(e) {
var workerResult = 'Hello, ' + e.data[0] + " " + e.data[1] + "!";
postMessage(workerResult);
}
Code: Select all
Procedure WorkerResponse(e)
rsp.s = ""
!v_rsp = v_e.data;
Debug rsp
EndProcedure
Procedure HelloWorker(firstname.s,surname.s)
EnableJS
var myWorker = new Worker('worker.js');
myWorker.onmessage = f_workerresponse;
myWorker.postMessage([v_firstname,v_surname]);
DisableJS
EndProcedure
HelloWorker("The","Weavster")
Re: Procedure freezes open window
I assume that Jarlve wants to write his time-consuming Procedure in SpiderBasic-Syntax and not in JavaScript.the.weavster wrote:But the WebWorker file is already separate:
Greetings ... Peter
-
- Posts: 222
- Joined: Sat Mar 01, 2014 3:02 pm
Re: Procedure freezes open window
I think while SB is in its early stages it will be very hard to avoid JS completely, it's probably better to embrace it and get used to combining the two.
For me at least the big bonus from using SB is avoiding HTML and CSS rather than avoiding JS
For me at least the big bonus from using SB is avoiding HTML and CSS rather than avoiding JS