title: Node.js - Pausing script execution in another thread
body: <p>.:Disclaimer:.</p>
  
  <p>Please note that I am trying to achieve something with node.js which might go against its design principles. However as node.js goes against the norm of "javascript is for client side", I am also trying something different here. Please bear with me. </p>
  
  <p>.:Background:.</p>
  
  <p>I have a requirement where Java Scripts need to be narrative (read from beginning to end) for simplistic scripts for simplistic users. I will also offer an Async scripting ability for more advanced users.  </p>
  
  <p>I understand the event driven methodology of node.js, and have a solution working based on Async callbacks. Now I am trying to simplify this for our more basic scripting requirements.  </p>
  
  <p>.:The Question:.</p>
  
  <p>Is there a way to run a script (using its own sandbox) where execution can be paused while a result is being delivered. </p>
  
  <p>E.g. </p>
  
  <pre><code>var util = require('util'),
  vm = require('vm'),
  user = require('user');
  
  vm.runInThisContext('user.WaitForProceed(); console.log('Waiting over');');
  
  console.log('Finished!');
  </code></pre>
  
  <p>User is my own module that will do the waiting. Basically I want it to sit there and block on that line in the vm object until it has received a result back. After which it will continue onto the console.log line.  </p>
  
  <p>The output of this example unimportant as it is also achievable through callbacks. The narrative nature of the example script is more important for this solution.</p>
  
  <ul>
  <li>J</li>
  </ul>