private void Link() { VirtualRoot.Window <CloseNTMinerCommand>("处理关闭NTMiner客户端命令", LogEnum.UserConsole, action: message => { UIThread.Execute(() => { try { if (MainWindow != null) { MainWindow.Close(); } Shutdown(); } catch (Exception e) { Logger.ErrorDebugLine(e.Message, e); Environment.Exit(0); } }); }); VirtualRoot.Window <CloseMainWindowCommand>("处理关闭主界面命令", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Write.SetConsoleUserLineMethod(); MainWindow = NotiCenterWindow.Instance; foreach (Window window in Windows) { if (window != NotiCenterWindow.Instance) { window.Close(); } } AppContext.Disable(); NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage("已切换为无界面模式运行", "开源矿工"); }); }); #region 周期确保守护进程在运行 Daemon.DaemonUtil.RunNTMinerDaemon(); VirtualRoot.On <Per20SecondEvent>("周期确保守护进程在运行", LogEnum.None, action: message => { if (NTMinerRegistry.GetDaemonActiveOn().AddSeconds(20) < DateTime.Now) { Daemon.DaemonUtil.RunNTMinerDaemon(); } }); #endregion #region 1080小药丸 VirtualRoot.On <MineStartedEvent>("开始挖矿后启动1080ti小药丸、挖矿开始后如果需要启动DevConsole则启动DevConsole", LogEnum.DevConsole, action: message => { // 启动DevConsole if (NTMinerRoot.IsUseDevConsole) { var mineContext = message.MineContext; string poolIp = mineContext.MainCoinPool.GetIp(); string consoleTitle = mineContext.MainCoinPool.Server; Daemon.DaemonUtil.RunDevConsoleAsync(poolIp, consoleTitle); } OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Start(); }); VirtualRoot.On <MineStopedEvent>("停止挖矿后停止1080ti小药丸", LogEnum.DevConsole, action: message => { OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Stop(); }); #endregion #region 处理开启A卡计算模式 VirtualRoot.Window <SwitchRadeonGpuCommand>("处理开启A卡计算模式命令", LogEnum.DevConsole, action: message => { if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD) { if (NTMinerRoot.Instance.IsMining) { NTMinerRoot.Instance.StopMineAsync(() => { SwitchRadeonGpuMode(); NTMinerRoot.Instance.StartMine(); }); } else { SwitchRadeonGpuMode(); } } }); #endregion }