Detecting/Aborting long running scripts
jasonswearingen opened this issue · 2 comments
jasonswearingen commented
it seems that scripts run via script.ExecuteCodeAsync()
do not yield unless the script itself includes await
. So if there is an infinite loop in a poorly written script the entire application blocks.
Is there a workaround for this? Ideally running a script via ExecuteCodeAsync()
did not block the caller, and a CancellationToken could be specified.
jasonswearingen commented
nevermind, I worked around this by passing the cancel token to the script.
RickStrahl commented
Sure you can work around this, but what happens in the code that is called is not under the control of the calling execution engine.
That's what async is for in which case you can pass in a Cancellation token to your method as you point out.