public void start() { try { WorkerPriority.GetJobPriority(job, out WorkerPriorityType oPriority, out bool lowIOPriority); processThread = new Thread(new ThreadStart(RunInThread)); processThread.Priority = OSInfo.GetThreadPriority(oPriority); processThread.Start(); new System.Windows.Forms.MethodInvoker(this.RunStatusCycle).BeginInvoke(null, null); } catch (Exception e) { throw new JobRunException(e); } }
public void changePriority(WorkerPriorityType priority) { if (!isRunning()) { return; } try { WorkerPriority.GetJobPriority(job, out WorkerPriorityType oPriority, out bool lowIOPriority); OSInfo.SetProcessPriority(proc, priority, lowIOPriority, iMinimumChildProcessCount); return; } catch (Exception e) // process could not be running anymore { throw new JobRunException(e); } }
public void start() { proc = new Process(); ProcessStartInfo pstart = new ProcessStartInfo(); pstart.FileName = executable; pstart.Arguments = Commandline; if (bCommandLine) { pstart.RedirectStandardOutput = true; pstart.RedirectStandardError = true; pstart.UseShellExecute = false; } pstart.WindowStyle = ProcessWindowStyle.Minimized; pstart.CreateNoWindow = true; proc.StartInfo = pstart; proc.EnableRaisingEvents = true; proc.Exited += new EventHandler(proc_Exited); bWaitForExit = false; log.LogValue("Job command line", '"' + pstart.FileName + "\" " + pstart.Arguments); try { bool started = proc.Start(); if (bFirstPass) { su.ResetTime(); } isProcessing = true; log.LogEvent("Process started"); stdoutLog = log.Info(string.Format("[{0:G}] {1}", DateTime.Now, "Standard output stream")); stderrLog = log.Info(string.Format("[{0:G}] {1}", DateTime.Now, "Standard error stream")); if (bCommandLine) { readFromStdErrThread = new Thread(new ThreadStart(readStdErr)); readFromStdOutThread = new Thread(new ThreadStart(readStdOut)); readFromStdOutThread.Start(); readFromStdErrThread.Start(); } new System.Windows.Forms.MethodInvoker(this.RunStatusCycle).BeginInvoke(null, null); if (hideProcess) { // try to hide the main window while (!proc.HasExited && !WindowUtil.GetIsWindowVisible(proc.MainWindowHandle)) { MeGUI.core.util.Util.Wait(100); } if (!proc.HasExited) { WindowUtil.HideWindow(proc.MainWindowHandle); } } WorkerPriority.GetJobPriority(job, out WorkerPriorityType oPriority, out bool lowIOPriority); this.changePriority(oPriority); } catch (Exception e) { throw new JobRunException(e); } }