public void run() { if (!File.Exists(exe)) { return; } list.Add(this); process = new Process(); try { process.EnableRaisingEvents = true; process.Exited += new EventHandler(runFinsihed); process.StartInfo.FileName = wrapQuotes(exe); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler); process.StartInfo.RedirectStandardError = true; process.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler); process.StartInfo.Arguments = arguments; process.Start(); // Start the asynchronous read of the standard output stream. process.BeginOutputReadLine(); process.BeginErrorReadLine(); } catch (Exception e) { conn.log(e.ToString(), false, 2); list.Remove(this); } }
public GCode PopData() { GCode gc = null; bool finished = false; lock (jobList) { if (jobList.Count == 0) { return(null); } try { gc = new GCode(jobList.First.Value); jobList.RemoveFirst(); linesSend++; /*PrintTime pt = new PrintTime(); * pt.line = linesSend; * pt.time = DateTime.Now.Ticks; * lock (times) * { * times.AddLast(pt); * if (times.Count > 1500) * times.RemoveFirst(); * }*/ } catch { }; finished = jobList.Count == 0 && mode != 3; } if (finished) { dataComplete = false; mode = 2; jobFinished = DateTime.Now; long ticks = (jobFinished.Ticks - jobStarted.Ticks) / 10000; long hours = ticks / 3600000; ticks -= 3600000 * hours; long min = ticks / 60000; ticks -= 60000 * min; long sec = ticks / 1000; //Main.conn.log("Printjob finished at " + jobFinished.ToShortDateString()+" "+jobFinished.ToShortTimeString(),false,3); con.log("L_PRINTJOB_FINISHED_AT", false, 3); StringBuilder s = new StringBuilder(); if (hours > 0) { s.Append("L_TIME_H:" + hours.ToString()); //"h:"); } if (min > 0 || hours > 0) { s.Append("L_TIME_M:" + min.ToString()); } s.Append("L_TIME_S" + sec.ToString()); //Main.conn.log("Printing time:"+s.ToString(),false,3); //Main.conn.log("Lines send:" + linesSend.ToString(), false, 3); //Main.conn.firePrinterAction("Finished in "+s.ToString()); con.log("L_PRINTING_TIME:" + s.ToString(), false, 3); con.log("L_LINES_SEND:X" + linesSend.ToString(), false, 3); con.firePrinterAction("L_FINISHED_IN" + s.ToString()); DoEndKillActions(); con.Main.main.UpdateJobButtons.Invoke(); //*/ Main.main.printPanel.Invoke(Main.main.printPanel.SetStatusJobFinished); // RepetierHost.view.SoundConfig.PlayPrintFinished(false); } return(gc); }