Any way to stop Run() "gracefully"?

Mar 10, 2011 at 4:36 PM


I'm launching engine.Run() from inside a BackgroundWorker thread, and since I'm doing it in a javascript editor/debugger and each time I write a character I have to restart the Run(), I need to stop the interpreter and restart again (think about a long time loop executing, I cannot wait for its ending).

Is there a graceful way to stop it, instead of aborting the thread with unpredictable result (leaks and so on)?


Thank you, Marco

Mar 11, 2011 at 11:14 AM

I don't know how graceful it is but this is what I did.  When I start the background worker thread with the run, I also start a timer that just sleeps and then sets a flag.  In the engine_step event, I check for this flag and if it is set, then I do not continue operation by throwing an exception.  I am sure that there are problems with this but it generally works.