I'm loading and invoking a csx file something like this:
BaseScript = new ScriptBase(); // My own type
var session = engine.CreateSession(BaseScript, typeof(ScriptBase));
BaseScript.Session = session;
//...
var script = File.ReadAllText(file);
BaseScript.Session.Execute(script);
This script is meant to run indefinitely, and basically has a while (true); in there. Is there a way for me to stop it prematurely?
Also, I'm thinking about moving to Mono.Csharp, would that allow me to do this? Maybe it's a better choice overall, thoughts?
So the answer is this: Roslyn doesn't interpret C#, it compiles it. When you call Execute(string), it actually executes it right then and there. I put the call in a new thread and Abort()ed it when I needed to, which isn't especially elegant, but I'm not sure what else to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With