Open jinha3411 opened 4 years ago
One option:
When you want to break the execution from the monitor thread create a hook:
void SetAbortProgramHook()
{
_lua.DebugHook += LuaAbortProgramHook;
_lua.SetDebugHook(KeraLua.LuaHookMask.Count, 1);
}
void LuaAbortProgramHook(object sender, NLua.Event.DebugHookEventArgs args)
{
_lua.Push("Execution aborted");
_lua.State.Error();
}
Note: this wont work if the execution thread is locked.
I currently have two thread : Monitoring thread that monitors LuaObject and flags & Execution Thread that actually runs the script.
What I am trying to achieve is to kill the running script (script that "DoFile"ed by Lua object) when the monitoring thread checks a certain flag (e.g., bool killscript = true).
I am new to Lua and having hard time to figure out.
Any hints would be much appreciated