[Ironruby-core] How can I cancel a running script

Aaron Clauson lists at ruby-forum.com
Sat Jun 6 02:59:07 EDT 2009


I have an IronRuby script running that I'd like to be able to cancel
from outside the script. Is there any way to do that?

  ScriptEngine scriptEngine = Ruby.CreateEngine();
  ScriptScope scriptScope = scriptEngine.CreateScope();
  string script =
    "print \"1\n\"\n" +
    "print \"2\n\"\n" +
    "sleep(10)\n" +
    "print \"3\n\"\n";
  ThreadPool.QueueUserWorkItem(delegate { scriptEngine.Execute(script,
scriptScope); });

In the above example how could I cancel the script to stop it getting to
3 without having to resort to aborting the thread it is running on?


Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list