public void Switch() { RunningTask = null; HashSet <TreeTask <TBb> > temp = CurrentlyRunning; CurrentlyRunning = PreviouslyRunning; PreviouslyRunning = temp; CurrentlyRunning.Clear(); }
public void RegisterRunning(TreeTask <TBb> task) { CurrentlyRunning.Add(task); // We remove it here to spare some cycles later on. if (task.PreviousTickState == TaskState.Running) { PreviouslyRunning.Remove(task); } // The first one to report running is the deepest running one if (RunningTask == null) { RunningTask = task; } }
public static void DeclarePrivateVarible(string line) { string[] args = line.Replace("(private)", "").StringSplit(" = "); args[1] = EggCodeParser.ParseInput(args[1]).ToString(); EggCodeTypeVarible var = new EggCodeTypeVarible(args[0], args[1]); if (CurrentlyRunning.FindVarible(args[0]) == null) { CurrentlyRunning.privateVaribles.Add(var); } else { CurrentlyRunning.privateVaribles[CurrentlyRunning.FindVaribleIndex(args[0])] = var; } }
public static object ParseInput(string input) { if (input.StartsWith("\"")) { return(input.Between("\"", "\"")); } else if (input.StartsWith("input")) { Console.Write(ParseInput(input.AdvancedBetween('(', ')'))); return(Console.ReadLine()); } else if (input.StartsWith("math")) { return(EggCodeCommands.Math(input)); } //if no other input method is found try to return a private varible but if there is no private varible try to return a global one else { try { try { return(CurrentlyRunning.FindVarible(input).value); } catch { return(EggCodeTypeVarible.FindVarible(input).value); } } catch { return(input); } } }
public void Run() { /* * FileInfo exeFileInfo = new FileInfo(exefile); * if(!exeFileInfo.Exists) { * Console.Error.WriteLine("unable to find file: '" + exeFileInfo.FullName + "'"); * return; * } * psi.FileName = exeFileInfo.FullName; * psi.WorkingDirectory = exeFileInfo.DirectoryName; */ ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = this.exefile; psi.Arguments = this.args; psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; Console.WriteLine("starting case {0} (exe '{1}' args '{2}')...", i + 1, psi.FileName, psi.Arguments); lock (synclock) { CurrentlyRunning.Add(i); } using (var stdout = new StreamWriter("out_" + (i + 1) + ".txt")) { using (var p = new Process()) { p.StartInfo = psi; DataReceivedEventHandler handler = delegate(object sender, DataReceivedEventArgs e) { try { stdout.WriteLine(e.Data); stdout.Flush(); } catch (Exception ee) { Console.WriteLine("FAILED " + (i + 1) + ": " + ee.Message + " (" + ee.GetType().FullName + ")"); throw; } return; }; p.OutputDataReceived += handler; p.ErrorDataReceived += handler; try { p.Start(); p.BeginErrorReadLine(); p.BeginOutputReadLine(); p.WaitForExit(); success = (p.ExitCode == 0); stdout.Flush(); Console.WriteLine("finished " + (i + 1) + ", exit code " + p.ExitCode); } catch (Exception e) { Console.WriteLine("FAILED " + (i + 1) + ": " + e.Message + " (" + e.GetType().FullName + ")"); stdout.WriteLine("FAILED " + (i + 1) + ": " + e.Message + " (" + e.GetType().FullName + ")"); success = false; } } stdout.Flush(); } int[] running; lock (synclock) { CurrentlyRunning.Remove(i); running = CurrentlyRunning.ToArray(); Console.Write("Currently running:"); foreach (int j in running) { Console.Write(" " + (j + 1)); } Console.WriteLine(";"); } Console.Out.Flush(); }