Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to allow a google desktop gadget to update its UI (handle user input) whilst the underlying code is busy/blocked?
    primarykey
    data
    text
    <p>Take your average google desktop gadget. Add the following code:</p> <blockquote> <pre><code> debug.trace("go!"); for (var i = 0; i &lt; 100000000; i++) { // google desktop stops responding j = 12 * i; } debug.trace("finished"); </code></pre> </blockquote> <p>All google desktop gadgets lock up / freeze for the duration, including the gadget the code is running in (the normal double-shift shortcut doesn't work, you can't move any gadgets or interact with them in any other way; the systray icon is responsive, but doesn't do anything - e.g. the options page isn't loaded till the code has finished).</p> <p>I'm looking for a way around this general situation (my case is I'm making external function calls via a DLL that take a long time to return, see <a href="http://code.google.com/apis/desktop/docs/script.html#gmanifest" rel="nofollow">gmanifest</a> 'install' element).</p> <p>Having the calls (/ above code) triggered via setInterval / setTimeout doesn't seem to make any difference, nor does any code that would normally be called by a timer get executed whilst the long call is taking place.</p> <p>I'm assuming this is possible, because when you try the following code in place of the busy loop or my blocking external function call, nothing locks up:</p> <blockquote> <pre><code> var wsh = new ActiveXObject("WScript.Shell"); wsh.run("cmd.exe",1,true); // true = block until program has exited // UI responds in this period debug.trace("finished"); // occurs when cmd.exe is closed </code></pre> </blockquote> <p>I don't know what the difference between these three cases is. Any ideas, and more importantly, any way around it?</p> <p>Thoughts:</p> <ul> <li><p>The busy loop isn't blocking as such, but just using up all processor time so nothing happens hence isn't representative (seems unlikely) [edit: no, it is blocking]</p></li> <li><p>The DLL or way I'm using it is broken or wrong, respectively (could be, I can add more details if needed) [edit: seems not, just a normal blocking call]</p></li> <li><p>google gadgets "knows about" wscript.shell and carries on going whilst "run" is blocking (seems unlikely) [edit: unanswered!]</p></li> <li><p>I could explicitly spawn a worker thread for the blocking code (I can't find anything on explicit thread control in gadgets) [edit: not possible; javascript has a single thread]</p></li> <li><p>Wrap up the block call in an external program, poll file for status updates (see answer)</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload