public void StartMiner(bool minimized) { _minimized = minimized; _process = new Process(); DeviceConfig firstDevice = DeviceConfigs.First(); string minerPath = Helpers.ResolveToFullPath(firstDevice.MinerPath, Helpers.GetApplicationRoot()); _port = firstDevice.MinerApiPort > 0 ? firstDevice.MinerApiPort : Helpers.GetAvailablePort(); string minerFolderPath = Path.GetDirectoryName(minerPath); _process.StartInfo.FileName = minerPath; List <string> userDefindedArgs = new List <string>(); if (!String.IsNullOrEmpty(firstDevice.MinerArguments)) { userDefindedArgs.AddRange(firstDevice.MinerArguments.Split(" ")); } string args = ""; string space = ""; if (!userDefindedArgs.Contains("-o")) { args = $"{space}-o {Pool.PoolUrl}"; space = " "; } if (!userDefindedArgs.Contains("-u")) { args += $"{space}-u {Pool.PoolUser}"; space = " "; } if (!userDefindedArgs.Contains("-p")) { args += $"{space}-p {Pool.PoolPassword}"; space = " "; } if (DeviceConfigs.All(dc => dc.DeviceType != DeviceType.CPU)) { if (!userDefindedArgs.Contains("--no-cpu")) { args += $"{space}--no-cpu"; space = " "; } } if (DeviceConfigs.Any(dc => dc.DeviceType == DeviceType.AMD)) { if (!userDefindedArgs.Contains("--opencl")) { args += $"{space}--opencl"; space = " "; } if (!userDefindedArgs.Any(a => a.StartsWith("--opencl-devices=", StringComparison.OrdinalIgnoreCase))) { args += $"{space}--opencl-devices={string.Join(',', DeviceConfigs.Where(dc => dc.DeviceType == DeviceType.AMD).Select(dc => dc.DeviceId))}"; space = " "; } } if (DeviceConfigs.Any(dc => dc.DeviceType == DeviceType.NVIDIA)) { if (!userDefindedArgs.Contains("--cuda")) { args += $"{space}--cuda"; space = " "; } if (!userDefindedArgs.Any(a => a.StartsWith("--opencl-devices=", StringComparison.OrdinalIgnoreCase))) { args += $"{space}--cuda-devices={string.Join(',', DeviceConfigs.Where(dc => dc.DeviceType == DeviceType.NVIDIA).Select(dc => dc.DeviceId))}"; space = " "; } } args += $"{space}--http-port={_port}"; space = " "; if (!String.IsNullOrEmpty(firstDevice.MinerArguments)) { args += space + firstDevice.MinerArguments; } _process.EnableRaisingEvents = true; _process.Exited += ProcessOnExited; _process.StartInfo.Arguments = args; _process.StartInfo.UseShellExecute = true; _process.StartInfo.CreateNoWindow = false; _process.StartInfo.RedirectStandardOutput = false; _process.StartInfo.WorkingDirectory = minerFolderPath; _process.StartInfo.WindowStyle = minimized ? ProcessWindowStyle.Minimized : ProcessWindowStyle.Normal; Log.Debug($"Miner Start Info: \"{_process.StartInfo.FileName}\" {_process.StartInfo.Arguments}"); _process.Start(); }