Script Async Operation

dave_galera

Well-known member
Juan, normally I am very reluctant to suggest any new features as I am aware you have more than enough to do, and you know in which direction you want to take PI, however some sort of async facility in scripts would be very very useful.

I don't know how the Mozilla's SpiderMonkey engine integrates with the PI core so I don't know if it would even be possible but would it be possible to add the following (at lease setTimeout would be useful):
setTimeout();
async function asyncCall() {}
new Promise(resolve => {});
await resolveTimer();

Or maybe a better option could be to implement a message Q pump system with a Q listener so we could do something like this within the SAME script:

this.control= new NumericControl (this);
.
.
this.control.onValueUpdated = function (value) {
CoreApplication.qmessage('q_id','msg_id', value);
};

let listener = new QListener;
listener.onMessage = function( qid, msg_id, message ) {
// Process value from control.onValue
};

This would then allow the numeric control to be continually adjust while any lengthy processing can be done by the listener routine asynchronously.
 
Back
Top