private void HandleProgressResult(int failureCount) { MessageBoxResult mresult = MessageBox.Show("修改配置完成,需要重启矿机服务后才能生效。需要现在重启所有修改过的矿机吗?", "确认", MessageBoxButton.YesNo); if (mresult == MessageBoxResult.No) { MinerManager.GetInstance().SaveCurrentInfo(); this.Close(); return; } // Restart the selected miners ProgressWindow progress = new ProgressWindow("正在重新启动矿机...", this.minerClients, (obj) => { MinerClient client = (MinerClient)obj; OKResult exeResult = client.ExecuteDaemon <OKResult>("-s stop"); exeResult = client.ExecuteDaemon <OKResult>("-s start"); }, (result) => { MinerManager.GetInstance().SaveCurrentInfo(); this.Close(); }, shouldPromptSummary: false ); progress.ShowDialog(); }
public MainWindow() { logger.Trace("Initializing MainWindow."); InitializeComponent(); minerManager = MinerManager.GetInstance(); InitializeUIData(); logger.Trace("Initialized MainWindow."); }
/// <summary> /// When changing instanceType for 2+ clients on the same machine, it might has a situation that they will have the same instanceId, /// So in this step the MinerManager would detect the conflicts then assign new instanceId when necessary. /// </summary> /// <param name="client"></param> /// <param name="returnedInstanceId"></param> /// <returns></returns> private int AssignInstanceId(string machineName, MinerClient.InstanceTypes instanceType, int newInstanceId) { int assignedInstanceId = newInstanceId; string key = machineName + instanceType.ToString() + assignedInstanceId.ToString(); MinerManager manager = MinerManager.GetInstance(); while (this.newInstanceIdDictionary.ContainsKey(key) || manager.IsInstanceIdExists(machineName, instanceType, assignedInstanceId)) { assignedInstanceId++; key = machineName + instanceType.ToString() + assignedInstanceId.ToString(); } this.newInstanceIdDictionary[key] = true; return(assignedInstanceId); }