protected void Stop_cpu_ccminer_sgminer_nheqminer(MinerStopType willswitch) { if (IsRunning) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Shutting down miner"); } if (ProcessHandle != null) { try { ProcessHandle.Kill(); } catch { } //try { ProcessHandle.SendCtrlC((uint)Process.GetCurrentProcess().Id); } catch { } ProcessHandle.Close(); ProcessHandle = null; // sgminer needs to be removed and kill by PID if (IsKillAllUsedMinerProcs) { KillAllUsedMinerProcesses(); } } }
virtual protected NiceHashProcess _Start() { // never start when ended if (isEnded) { return(null); } PreviousTotalMH = 0.0; if (LastCommandLine.Length == 0) { return(null); } NiceHashProcess P = new NiceHashProcess(); if (WorkingDirectory.Length > 1) { P.StartInfo.WorkingDirectory = WorkingDirectory; } if (MinersSettingsManager.MinerSystemVariables.ContainsKey(Path)) { foreach (var kvp in MinersSettingsManager.MinerSystemVariables[Path]) { string envName = kvp.Key; string 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 MinerPID_Data(); _currentPidData.minerBinPath = P.StartInfo.FileName; _currentPidData.PID = P.Id; _allPidData.Add(_currentPidData); Helpers.ConsolePrint(MinerTAG(), "Starting miner " + ProcessTag() + " " + LastCommandLine); StartCoolDownTimerChecker(); return(P); } else { Helpers.ConsolePrint(MinerTAG(), "NOT STARTED " + ProcessTag() + " " + LastCommandLine); return(null); } } catch (Exception ex) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " _Start: " + ex.Message); return(null); } }