private void OverlayTask(GoodsDownloadPauseEventArgs e) { try { int time = e.WaitSeconds; this.Dispatcher.BeginInvoke(new Action(() => this.overlay.Visibility = Visibility.Visible)); while (time >= 0) { string msg = "检测到:淘宝返回操作过于频繁,将于:" + time + "秒后自动重试"; this.Dispatcher.BeginInvoke(new Action(() => this.tbCount.Text = msg)); Thread.Sleep(1000); time--; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Dispatcher.BeginInvoke(new Action(() => this.overlay.Visibility = Visibility.Collapsed)); if (this.goodsDownloadWorker != null) { this.goodsDownloadWorker.GoOn(); } } }
private void GoodsDownloadWorker_Pausing(object sender, GoodsDownloadPauseEventArgs e) { if (e.Msg == "用户暂停") { return; } this.Dispatcher.BeginInvoke(new Action(() => { if (e.IsVerify) { MessageBox.Show("登录超时需要登录验证,进行操作后点击继续"); } else { Task.Factory.StartNew(new Action(() => OverlayTask(e))); } })); }