private void GetStrThread() { try { if (!_book.GetDownloadUrl(this)) { String str = null; ManualResetEvent mre = null; this.Dispatcher.Invoke(new Action(() => { mre = StrInputBox.showInputBox(_book); })); mre.WaitOne(); this.Dispatcher.Invoke(new Action(() => { str = StrInputBox.GetString(); })); if (str != null) { _book.GetDownloadUrlByStr(str); } else { throw new Exception("找不到STR"); } } this.Dispatcher.Invoke(new Action(() => status.Content = "正在下载")); Status = TaskStatus.Downloading; _download.Start(); } catch (Exception e) { if (e is ThreadAbortException) { return; } DownloadFailed(e.Message); } }
public StrInputBox() { InitializeComponent(); Instance = this; mre = new ManualResetEvent(false); }