protected virtual Process BenchmarkStartProcess(string commandLine) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Helpers.ConsolePrint(MinerTag(), "Starting benchmark: " + commandLine); var benchmarkHandle = new Process { StartInfo = { FileName = MiningSetup.MinerPath } }; // sgminer quickfix if (this is Sgminer) { BenchmarkProcessPath = "cmd / " + benchmarkHandle.StartInfo.FileName; benchmarkHandle.StartInfo.FileName = "cmd"; } else { BenchmarkProcessPath = benchmarkHandle.StartInfo.FileName; Helpers.ConsolePrint(MinerTag(), "Using miner: " + benchmarkHandle.StartInfo.FileName); benchmarkHandle.StartInfo.WorkingDirectory = WorkingDirectory; } // set sys variables if (MinersSettingsManager.MinerSystemVariables.ContainsKey(Path)) { foreach (var kvp in MinersSettingsManager.MinerSystemVariables[Path]) { var envName = kvp.Key; var envValue = kvp.Value; benchmarkHandle.StartInfo.EnvironmentVariables[envName] = envValue; } } benchmarkHandle.StartInfo.Arguments = commandLine; benchmarkHandle.StartInfo.UseShellExecute = false; benchmarkHandle.StartInfo.RedirectStandardError = true; benchmarkHandle.StartInfo.RedirectStandardOutput = true; benchmarkHandle.StartInfo.CreateNoWindow = true; benchmarkHandle.OutputDataReceived += BenchmarkOutputErrorDataReceived; benchmarkHandle.ErrorDataReceived += BenchmarkOutputErrorDataReceived; benchmarkHandle.Exited += BenchmarkHandle_Exited; if (!benchmarkHandle.Start()) { return(null); } _currentPidData = new MinerPidData { MinerBinPath = benchmarkHandle.StartInfo.FileName, Pid = benchmarkHandle.Id }; _allPidData.Add(_currentPidData); return(benchmarkHandle); }
protected virtual NiceHashProcess _Start() { // never start when ended if (_isEnded) { return(null); } PreviousTotalMH = 0.0; if (LastCommandLine.Length == 0) { return(null); } var P = new NiceHashProcess(); if (WorkingDirectory.Length > 1) { P.StartInfo.WorkingDirectory = WorkingDirectory; } if (MinersSettingsManager.MinerSystemVariables.ContainsKey(Path)) { foreach (var kvp in MinersSettingsManager.MinerSystemVariables[Path]) { var envName = kvp.Key; var envValue = kvp.Value; P.StartInfo.EnvironmentVariables[envName] = envValue; } } P.StartInfo.FileName = Path; P.ExitEvent = Miner_Exited; P.StartInfo.Arguments = LastCommandLine; if (IsNeverHideMiningWindow) { P.StartInfo.CreateNoWindow = false; if (ConfigManager.GeneralConfig.HideMiningWindows || ConfigManager.GeneralConfig.MinimizeMiningWindows) { P.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; P.StartInfo.UseShellExecute = true; } } else { P.StartInfo.CreateNoWindow = ConfigManager.GeneralConfig.HideMiningWindows; } P.StartInfo.UseShellExecute = false; try { if (P.Start()) { IsRunning = true; _currentPidData = new MinerPidData { MinerBinPath = P.StartInfo.FileName, Pid = P.Id }; _allPidData.Add(_currentPidData); Helpers.ConsolePrint(MinerTag(), "Starting miner " + ProcessTag() + " " + LastCommandLine); StartCoolDownTimerChecker(); return(P); } Helpers.ConsolePrint(MinerTag(), "NOT STARTED " + ProcessTag() + " " + LastCommandLine); return(null); } catch (Exception ex) { Helpers.ConsolePrint(MinerTag(), ProcessTag() + " _Start: " + ex.Message); return(null); } }
private static string ProcessTag(MinerPidData pidData) { return($"[pid({pidData.Pid})|bin({pidData.MinerBinPath})]"); }