public int BeginExecute(string script)
 {
     var scriptId = this.scriptIdx++;
     var info = new ScriptExecutionInfo(script, scriptId);
     this.runningScripts.Add(info);
     this.executions.Add(info);
     var threadStart = new ThreadStart(() => Execute(info));
     this.scriptThread = new Thread(threadStart);
     this.scriptThread.Start();
     return scriptId;
 }
        void Execute(ScriptExecutionInfo info)
        {
            var sw = Stopwatch.StartNew();
            try
            {
                var src = Engine.CreateScriptSourceFromString(info.ScriptText);

                src.Execute(scope);
                sw.Stop();
                info.FinishedSuccess(sw.Elapsed);
            }
            catch (Exception ex)
            {
                this.LastException = ex;
                sw.Stop();
                info.FinishedException(sw.Elapsed, ex);
            } finally
            {
                this.runningScripts.Remove(info);
            }
        }