Razov

Member
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

111 Neutral

About Razov

  • Rank
    Newbie
  1. Thats not the point. I am using [url="http://luaforge.net/projects/luainterface/"]LuaInterface[/url] for C#. I am creating an application, where user can write his own lua code and execute it (new thread). I want to have possiblity to stop (interput) the execution of this lua code from C#. Lets see an example: Lets say there is such application: [img]http://i.imgur.com/gJQP6.png[/img] When You change "[b]Enabled[/b]" CheckBox Checked to [color=#008000][b]true[/b][/color], lua executes onEnabled function (this part is already done.), witch starts loop When You change "[b]Enabled[/b]" CheckBox Checked to [color=#b22222][b]false[/b][/color], execution of lua (there is loop running) [b]is terminated/stoped[/b], but lua variables stays untoutched (not cleaned) When You press "[b]RELOAD[/b]" button, execution of lua is stopped (if its running), then lua enverionment is cleared, and lua code from textbox is executed, so user can make changes to it and press reload. Example output it would give: [CODE] ["Enabled" Checked=true] eC: 1 / wC: 1 eC: 1 / wC: 2 eC: 1 / wC: 3 ["Enabled" Checked=false] [time passes, nothing appears on log...] ["Enabled" Checked=true] eC: 2 / wC: 4 eC: 2 / wC: 5 [RELOAD pressed] eC: 1 / wC: 1 eC: 1 / wC: 2 ... [/CODE] [size=5][b]The main problem i am facing right now is how i can stop execution of running lua code from c#?[/b][/size]
  2. Hello, lets say that i have got such code: [CODE] String script = @" writeConsole("Starting.") while true do writeConsole("I am alive...") sleep(1000) end"; Lua lua = new Lua(); lua.DoString(script); [/CODE] witch after executed in new thread keeps writing "I am alive..." evry second, like: [CODE] Starting. I am alive... I am alive... I am alive... ..... [/CODE] Is there any way to stop executing this loop (or any other lua script witch is in middle of execution at given point) from other thread ? And to reload execution of this script, so it will give output like this: [CODE] Starting. I am alive... I am alive... I am alive... Starting. // stop execution and start again in this place I am alive... I am alive... [/CODE]