Prevent Lua infinite loop

前端 未结 5 1825
暖寄归人
暖寄归人 2020-12-19 02:24

I use lua interfaces to get lua support in my C# program, the worker thread will freeze if the user submits code like this

while true do end
<
5条回答
  •  春和景丽
    2020-12-19 02:38

    I have used two techniques to address this issue. The first is to call the DoFile or DoString method inside a separate Task. That way you can abort the thread. I do not know of any technique (say from within a hook) to exit the interpreter.

    Another way would be to setup a separate Appdomain. Using this you can also set separate constraints (evidence and permission set) see CreateDomain for details.

提交回复
热议问题