// 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();
}
}
}