Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Waiting for input

0
0
Hi Fraysa,

Like any other code, script code can invoke modal or blocking APIs. Your SendYesNo function could be made to await user input before returning to its (script-based) caller; in fact, its signature implies that it does just that, as it returns the user's selection. You could also expose a function that just waits for input. It all depends on your application's architecture.

Script code can also use asynchronous programming techniques to avoid tying up threads while waiting for input. This might be a good idea on the server if you expect to have many scripts in flight concurrently, but heavy use of callbacks will make your script code less straightforward.

Unfortunately there's no way to suspend script execution externally and save its state for subsequent resumption. The operating system can do that at the thread level, but here again script code is no different from other code.

Cheers!

Viewing all articles
Browse latest Browse all 2297