public IncreaseLoadCounterAndMessage ( string infoMsg ) : void | ||
infoMsg | string | |
리턴 | void |
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { _startupTimer.Stop(); _startupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(International.GetText("NET45_Not_Installed_msg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); Close(); return; } if (!Helpers.Is64BitOperatingSystem) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Avaliable ComputeDevices ComputeDeviceManager.Query.QueryDevices(_loadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); _loadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; _loadingScreen.IncreaseLoadCounterAndMessage( International.GetText("Form_Main_loadtext_CheckLatestVersion")); _minerStatsCheck = new Timer(); _minerStatsCheck.Tick += MinerStatsCheck_Tick; _minerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; //_smaMinerCheck = new Timer(); //_smaMinerCheck.Tick += SMAMinerCheck_Tick; //_smaMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + // R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); //if (ComputeDeviceManager.Group.ContainsAmdGpus) //{ // _smaMinerCheck.Interval = // (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + // ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + // R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); //} _loadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); // Init ws connection NiceHashStats.OnBalanceUpdate += BalanceCallback; NiceHashStats.OnSmaUpdate += SmaCallback; NiceHashStats.OnVersionUpdate += VersionUpdateCallback; NiceHashStats.OnConnectionLost += ConnectionLostCallback; NiceHashStats.OnConnectionEstablished += ConnectionEstablishedCallback; NiceHashStats.OnVersionBurn += VersionBurnCallback; NiceHashStats.StartConnection(Links.NhmSocketAddress); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } _loadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); _bitcoinExchangeCheck = new Timer(); _bitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; _bitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second _bitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); _loadingScreen.IncreaseLoadCounterAndMessage( International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); Helpers.SetDefaultEnvironmentVariables(); _loadingScreen.IncreaseLoadCounterAndMessage( International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); _loadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { _loadingScreen.SetInfoMsg(International.GetText("Form_Main_loadtext_NVIDIAP0State")); Helpers.SetNvidiaP0State(); } _loadingScreen.FinishLoad(); var runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { var downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); var pHandle = new Process { StartInfo = { FileName = Application.ExecutablePath } }; pHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { var download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); var pHandle = new Process { StartInfo = { FileName = Application.ExecutablePath } }; pHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime _isManuallyStarted = true; if (StartMining(true) != StartMiningReturnType.StartMining) { _isManuallyStarted = false; StopMining(); } } }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(International.GetText("NET45_Not_Intsalled_msg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; if (!Helpers.InternalCheckIsWow64()) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // Query Avaliable ComputeDevices ComputeDeviceQueryManager.Instance.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.Instance.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDevice.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.AutoSaveChange = true; devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.Instance.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.Instance.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.Instance.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceGroupManager.Instance.GetGroupCount(DeviceGroupType.AMD_OpenCL) > 0) { SMAMinerCheck.Interval = (ConfigManager.Instance.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.Instance.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.Instance.GeneralConfig.SwitchMinSecondsDynamic * 1000); } UpdateCheck = new Timer(); UpdateCheck.Tick += UpdateCheck_Tick; UpdateCheck.Interval = 1000 * 3600; // every 1 hour UpdateCheck.Start(); UpdateCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); SMACheck = new SystemTimer(); SMACheck.Elapsed += SMACheck_Tick; SMACheck.Interval = 60 * 1000 * 2; // every 2 minutes SMACheck.Start(); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } SMACheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashBalance")); BalanceCheck = new Timer(); BalanceCheck.Tick += BalanceCheck_Tick; BalanceCheck.Interval = 61 * 1000 * 5; // every ~5 minutes BalanceCheck.Start(); BalanceCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); SetEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.Instance.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.Instance.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_loadtext_NVIDIAP0State")); try { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "nvidiasetp0state.exe"; psi.Verb = "runas"; psi.UseShellExecute = true; psi.CreateNoWindow = true; Process p = Process.Start(psi); p.WaitForExit(); if (p.ExitCode != 0) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state returned error code: " + p.ExitCode.ToString()); } else { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state all OK"); } } catch (Exception ex) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state error: " + ex.Message); } } LoadingScreen.FinishLoad(); // check if download needed if (!MinersDownloadManager.Instance.IsMinersBinsInit() && !ConfigManager.Instance.GeneralConfig.DownloadInit) { _downloadUnzipForm = new Form_Loading(); SetChildFormCenter(_downloadUnzipForm); _downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersDownloadManager.Instance.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.Instance.GeneralConfig.DownloadInit = false; ConfigManager.Instance.GeneralConfig.Commit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } // no bots please if (ConfigManager.Instance.GeneralConfig.hwidLoadFromFile && !ConfigManager.Instance.GeneralConfig.hwidOK) { var result = MessageBox.Show("NiceHash Miner has detected change of hardware ID. If you did not download and install NiceHash Miner, your computer may be compromised. In that case, we suggest you to install an antivirus program or reinstall your Windows.\r\n\r\nContinue with NiceHash Miner?", //International.GetText("Form_Main_msgbox_anti_botnet_msgbox"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { Close(); return; } else { // users agrees he installed it so commit changes ConfigManager.Instance.GeneralConfig.Commit(); } } else { if (ConfigManager.Instance.GeneralConfig.AutoStartMining) { buttonStartMining_Click(null, null); } } }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(International.GetText("NET45_Not_Installed_msg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } if (!Helpers.Is64BitOperatingSystem) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Avaliable ComputeDevices ComputeDeviceManager.Query.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceManager.Group.ContainsAMD_GPUs) { SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); // Init ws connection NiceHashStats.OnBalanceUpdate += BalanceCallback; NiceHashStats.OnSMAUpdate += SMACallback; NiceHashStats.OnVersionUpdate += VersionUpdateCallback; NiceHashStats.OnConnectionLost += ConnectionLostCallback; NiceHashStats.OnConnectionEstablished += ConnectionEstablishedCallback; NiceHashStats.OnVersionBurn += VersionBurnCallback; NiceHashStats.StartConnection(Links.NHM_Socket_Address); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); Helpers.SetDefaultEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_loadtext_NVIDIAP0State")); try { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "nvidiasetp0state.exe"; psi.Verb = "runas"; psi.UseShellExecute = true; psi.CreateNoWindow = true; Process p = Process.Start(psi); p.WaitForExit(); if (p.ExitCode != 0) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state returned error code: " + p.ExitCode.ToString()); } else { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state all OK"); } } catch (Exception ex) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state error: " + ex.Message); } } LoadingScreen.FinishLoad(); bool runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { Form_Loading downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { Form_Loading download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } // no bots please if (ConfigManager.GeneralConfigHwidLoadFromFile() && !ConfigManager.GeneralConfigHwidOK()) { var result = MessageBox.Show("NiceHash Miner Legacy has detected change of hardware ID. If you did not download and install NiceHash Miner Legacy, your computer may be compromised. In that case, we suggest you to install an antivirus program or reinstall your Windows.\r\n\r\nContinue with NiceHash Miner Legacy?", //International.GetText("Form_Main_msgbox_anti_botnet_msgbox"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { Close(); return; } else { // users agrees he installed it so commit changes ConfigManager.GeneralConfigFileCommit(); } } else { if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime IsManuallyStarted = true; if (StartMining(true) != StartMiningReturnType.StartMining) { IsManuallyStarted = false; StopMining(); } } } }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { _startupTimer.Stop(); _startupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(Tr("NiceHash Miner Legacy requires .NET Framework 4.5 or higher to work properly. Please install Microsoft .NET Framework 4.5"), Tr("Warning!"), MessageBoxButtons.OK); Close(); return; } if (!Helpers.Is64BitOperatingSystem) { MessageBox.Show(Tr("NiceHash Miner Legacy supports only x64 platforms. You will not be able to use NiceHash Miner Legacy with x86"), Tr("Warning!"), MessageBoxButtons.OK); Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Available ComputeDevices ComputeDeviceManager.Query.QueryDevices(_loadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); _loadingScreen.IncreaseLoadCounterAndMessage(Tr("Saving config...")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Available.Devices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; _loadingScreen.IncreaseLoadCounterAndMessage( Tr("Checking for latest version...")); _minerStatsCheck = new Timer(); _minerStatsCheck.Tick += MinerStatsCheck_Tick; _minerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; //_smaMinerCheck = new Timer(); //_smaMinerCheck.Tick += SMAMinerCheck_Tick; //_smaMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + // R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); //if (ComputeDeviceManager.Group.ContainsAmdGpus) //{ // _smaMinerCheck.Interval = // (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + // ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + // R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); //} _loadingScreen.IncreaseLoadCounterAndMessage(Tr("Getting NiceHash SMA information...")); // Init ws connection NiceHashStats.OnBalanceUpdate += BalanceCallback; NiceHashStats.OnSmaUpdate += SmaCallback; NiceHashStats.OnVersionUpdate += VersionUpdateCallback; NiceHashStats.OnConnectionLost += ConnectionLostCallback; NiceHashStats.OnConnectionEstablished += ConnectionEstablishedCallback; NiceHashStats.OnVersionBurn += VersionBurnCallback; NiceHashStats.OnExchangeUpdate += ExchangeCallback; NiceHashStats.StartConnection(Links.NhmSocketAddress); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } _loadingScreen.IncreaseLoadCounterAndMessage(Tr("Getting Bitcoin exchange rate...")); //// Don't start timer if socket is giving data //if (ExchangeRateApi.ExchangesFiat == null) //{ // // Wait a bit and check again // Thread.Sleep(1000); // if (ExchangeRateApi.ExchangesFiat == null) // { // Helpers.ConsolePrint("NICEHASH", "No exchange from socket yet, getting manually"); // _bitcoinExchangeCheck = new Timer(); // _bitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; // _bitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second // _bitcoinExchangeCheck.Start(); // BitcoinExchangeCheck_Tick(null, null); // } //} _loadingScreen.IncreaseLoadCounterAndMessage( Tr("Setting environment variables...")); Helpers.SetDefaultEnvironmentVariables(); _loadingScreen.IncreaseLoadCounterAndMessage( Tr("Setting Windows error reporting...")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); _loadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { _loadingScreen.SetInfoMsg(Tr("Changing all supported NVIDIA GPUs to P0 state...")); Helpers.SetNvidiaP0State(); } _loadingScreen.FinishLoad(); var runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { var downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(Tr("There are missing files from last Miners Initialization. Please make sure that your anti-virus is not blocking the application. NiceHash Miner Legacy might not work properly without missing files. Click Yes to reinitialize NiceHash Miner Legacy to try to fix this issue."), Tr("Warning!"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); var pHandle = new Process { StartInfo = { FileName = Application.ExecutablePath } }; pHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { var download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(Tr("There are missing files from last Miners Initialization. Please make sure that your anti-virus is not blocking the application. NiceHash Miner Legacy might not work properly without missing files. Click Yes to reinitialize NiceHash Miner Legacy to try to fix this issue."), Tr("Warning!"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); var pHandle = new Process { StartInfo = { FileName = Application.ExecutablePath } }; pHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime _isManuallyStarted = true; if (StartMining(false) != StartMiningReturnType.StartMining) { _isManuallyStarted = false; StopMining(); } } }
private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; // get all CPUs CPUs = CPUID.GetPhysicalProcessorCount(); // get all cores (including virtual - HT can benefit mining) int ThreadsPerCPU = CPUID.GetVirtualCoresCount() / CPUs; if (!Helpers.InternalCheckIsWow64() && !Config.ConfigData.AutoStartMining) { MessageBox.Show(International.GetText("form1_msgbox_CPUMining64bitMsg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Warning); CPUs = 0; } if (ThreadsPerCPU * CPUs > 64) { MessageBox.Show(International.GetText("form1_msgbox_CPUMining64CoresMsg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Warning); CPUs = 0; } int ThreadsPerCPUMask = ThreadsPerCPU; ThreadsPerCPU -= Config.ConfigData.LessThreads; if (ThreadsPerCPU < 1) { MessageBox.Show(International.GetText("form1_msgbox_CPUMiningLessThreadMsg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Warning); CPUs = 0; } Globals.Miners = new Miner[CPUs + 4]; if (CPUs == 1) { Globals.Miners[0] = new cpuminer(0, ThreadsPerCPU, 0); } else { for (int i = 0; i < CPUs; i++) { Globals.Miners[i] = new cpuminer(i, ThreadsPerCPU, CPUID.CreateAffinityMask(i, ThreadsPerCPUMask)); } } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_NVIDIA5X")); Globals.Miners[CPUs] = new ccminer_sp(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_NVIDIA3X")); Globals.Miners[CPUs + 1] = new ccminer_tpruvot(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_NVIDIA2X")); Globals.Miners[CPUs + 2] = new ccminer_tpruvot_sm21(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_AMD")); Globals.Miners[CPUs + 3] = new sgminer(); // Auto uncheck CPU if any GPU is found for (int i = 0; i < CPUs; i++) { try { if ((Globals.Miners[CPUs + 0].CDevs.Count > 0 || Globals.Miners[CPUs + 1].CDevs.Count > 0 || Globals.Miners[CPUs + 2].CDevs.Count > 0 || Globals.Miners[CPUs + 3].CDevs.Count > 0) && i < CPUs) { Globals.Miners[i].CDevs[0].Enabled = false; } } catch { } } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_SaveConfig")); for (int i = 0; i < Globals.Miners.Length; i++) { if (Config.ConfigData.Groups.Length > i) { Globals.Miners[i].ExtraLaunchParameters = Config.ConfigData.Groups[i].ExtraLaunchParameters; Globals.Miners[i].UsePassword = Config.ConfigData.Groups[i].UsePassword; Globals.Miners[i].MinimumProfit = Config.ConfigData.Groups[i].MinimumProfit; Globals.Miners[i].DaggerHashimotoGenerateDevice = Config.ConfigData.Groups[i].DaggerHashimotoGenerateDevice; if (Config.ConfigData.Groups[i].APIBindPort > 0) { Globals.Miners[i].APIPort = Config.ConfigData.Groups[i].APIBindPort; } for (int z = 0; z < Config.ConfigData.Groups[i].Algorithms.Length && z < Globals.Miners[i].SupportedAlgorithms.Length; z++) { Globals.Miners[i].SupportedAlgorithms[z].BenchmarkSpeed = Config.ConfigData.Groups[i].Algorithms[z].BenchmarkSpeed; Globals.Miners[i].SupportedAlgorithms[z].ExtraLaunchParameters = Config.ConfigData.Groups[i].Algorithms[z].ExtraLaunchParameters; Globals.Miners[i].SupportedAlgorithms[z].UsePassword = Config.ConfigData.Groups[i].Algorithms[z].UsePassword; Globals.Miners[i].SupportedAlgorithms[z].Skip = Config.ConfigData.Groups[i].Algorithms[z].Skip; Globals.Miners[i].SupportedAlgorithms[z].DisabledDevice = new bool[Globals.Miners[i].CDevs.Count]; if (Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices != null) { if (Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices.Length < Globals.Miners[i].CDevs.Count) { for (int j = 0; j < Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices.Length; j++) { Globals.Miners[i].SupportedAlgorithms[z].DisabledDevice[j] = Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices[j]; } for (int j = Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices.Length; j < Globals.Miners[i].CDevs.Count; j++) { Globals.Miners[i].SupportedAlgorithms[z].DisabledDevice[j] = false; } } else { for (int j = 0; j < Globals.Miners[i].CDevs.Count; j++) { Globals.Miners[i].SupportedAlgorithms[z].DisabledDevice[j] = Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices[j]; } } } else { Globals.Miners[i].GetDisabledDevicePerAlgo(); } } } else { Globals.Miners[i].GetDisabledDevicePerAlgo(); } for (int k = 0; k < Globals.Miners[i].CDevs.Count; k++) { ComputeDevice D = Globals.Miners[i].CDevs[k]; if (Config.ConfigData.Groups.Length > i) { D.Enabled = true; for (int z = 0; z < Config.ConfigData.Groups[i].DisabledDevices.Length; z++) { if (Config.ConfigData.Groups[i].DisabledDevices[z] == k) { D.Enabled = false; break; } } } ListViewItem lvi = new ListViewItem(); lvi.SubItems.Add(D.Vendor); lvi.SubItems.Add(D.Name); lvi.Checked = D.Enabled; lvi.Tag = D; listViewDevices.Items.Add(lvi); } } Config.RebuildGroups(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = Config.ConfigData.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000); if (Globals.Miners[CPUs + 3].CDevs.Count > 0) { SMAMinerCheck.Interval = (Config.ConfigData.SwitchMinSecondsAMD + Config.ConfigData.SwitchMinSecondsFixed) * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000); } UpdateCheck = new Timer(); UpdateCheck.Tick += UpdateCheck_Tick; UpdateCheck.Interval = 1000 * 3600; // every 1 hour UpdateCheck.Start(); UpdateCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_GetNiceHashSMA")); SMACheck = new Timer(); SMACheck.Tick += SMACheck_Tick; SMACheck.Interval = 60 * 1000; // every 60 seconds SMACheck.Start(); SMACheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_GetNiceHashBalance")); BalanceCheck = new Timer(); BalanceCheck.Tick += BalanceCheck_Tick; BalanceCheck.Interval = 61 * 1000; // every 61 seconds BalanceCheck.Start(); BalanceCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_SetEnvironmentVariable")); SetEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("form1_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(Config.ConfigData.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (Config.ConfigData.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("form1_loadtext_NVIDIAP0State")); try { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "nvidiasetp0state.exe"; psi.Verb = "runas"; psi.UseShellExecute = true; psi.CreateNoWindow = true; Process p = Process.Start(psi); p.WaitForExit(); if (p.ExitCode != 0) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state returned error code: " + p.ExitCode.ToString()); } else { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state all OK"); } } catch (Exception ex) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state error: " + ex.Message); } } LoadingScreen.IncreaseLoadCounter(); }