private void DelegateOp() { ShowList showList = InitializeList; showList += ShowDataList; showList?.Invoke(); }
/// <summary> /// 移除 /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="model"></param> public override async void Del <TModel>(TModel model) { try { DisplayMetro = System.Windows.Visibility.Visible; var selectModel = HotGames.Where(s => s.IsSelected).ToList(); if (selectModel.Any()) { List <int> gameIds = new List <int>(); selectModel.ForEach((ary) => gameIds.Add(ary.id)); IHome user = BridgeFactory.BridgeManager.GetHomeManager(); var genrator = await user.UpdateCommomUseGames(gameIds, "0"); if (genrator.code.Equals("000")) { ShowList?.Invoke(); } else { Msg.Info(genrator.Message); } } else { Msg.Info("请勾选您需要的游戏"); } } catch (Exception ex) { Msg.Error(ex); } finally { DisplayMetro = System.Windows.Visibility.Collapsed; } }
/// <summary> /// 下载文件 /// </summary> public override void Query() { try { stuepGo?.Invoke(); //计时器 System.Windows.Forms.Timer tm = new System.Windows.Forms.Timer(); tm.Interval = 1; tm.Tick += new EventHandler(tm_Tick); autoViewEvent = new AutoResetEvent(false); MeterInfo meterInfo = new MeterInfo() { gamesId = PageCollection.gameId, manualReset = tm }; takMeter.Add(meterInfo); tm.Start(); #region 载方法 List <dynamic> dynamics = new List <dynamic>(); dwonloadEntities.ForEach((ary) => { ary.downStuep = PageCollection.StrupPath; dynamics.Add(ary); }); PageCollection.dwonloadAllEntities = dynamics; CommonsCall.UserGames.Add(PageCollection); thread = new Thread(() => { autoViewEvent.WaitOne(); //阻塞当前线程,等待通知以继续执行 threadCount = 0; if (dwonloadEntities.Count == 1) { threadCount = 1; } dwonloadEntities.ForEach(d => { autoViewEvent.WaitOne(); //阻塞当前线程,等待通知以继续执行 d.Down_tm = new System.Windows.Forms.Timer(); d.Down_tm.Interval = 1; d.autoEvent.Set(); //通知阻塞的线程继续执行 d.Down_tm.Tick += new EventHandler(d.tm_Tick); d.Down_tm.Start(); threadCount++; d.td = new Thread(() => { threadCount = d.DownFile(d.url, threadCount); }); d.td.IsBackground = false; d.td.Start(); while (threadCount > 1) { Thread.Sleep(2); } GC.Collect(); }); GC.Collect(); //創建快捷方式 var curGameId = dwonloadEntities.First().gameId; var curModel = CommonsCall.UserGames.Where(s => s.gameId.Equals(curGameId)).First(); var pathName = curModel.dwonloadAllEntities.First().name.Substring(0, curModel.dwonloadAllEntities.First().name.Length - 4); var path = curModel.StrupPath + @"\" + pathName + @"\" + curModel.startFileName; if (curModel.IsSelected) { CommonsCall.CreateShortcut(curModel); } Process.Start(path); stuepEnd?.Invoke(path, curModel.startFileName); CommonsCall.HyGameInstall(curGameId.ToString(), path, curModel.startFileName); System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { CommonsCall.UserGames.Remove(curModel); })); }); thread.IsBackground = false; thread.Start(); aTimer = new System.Timers.Timer(); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Interval = 2000; aTimer.Enabled = true; aTimer.Start(); #endregion } catch (Exception ex) { Msg.Error(ex); } finally { ShowList?.Invoke(); } }