Forum: IronRuby How can I cancel a running script

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6beced7e1914e4ed0b7232c73e6eac43?d=identicon&s=25 Aaron Clauson (aaronc)
on 2009-06-06 08:59

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?


Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-06-06 19:18
(Received via mailing list)
The script itself might check some (global) variable time to time and if
it is "on" terminate itself. For example, use Kernel#select with a
timeout instead of sleep.

This topic is locked and can not be replied to.