/// <summary> /// 选择当前节点的下一个可见节点。 /// </summary> /// <param name="click">是否对其执行单击操作。</param> /// <returns></returns> public bool SelectNextNode(bool click) { _asyncHandle.Wait(); this.UpdateSelectedNode(); IntPtr root = _selectedNode; IntPtr child = IntPtr.Zero; if (root != IntPtr.Zero) { ClickNode(root); _treeView.ExpandNode(root); } child = _treeView.GetFirstChildItem(root); if (child == IntPtr.Zero) { child = _treeView.GetNextNode(root); } if (child == IntPtr.Zero) { child = _treeView.GetNextVisible(root); } if (child != IntPtr.Zero && click) { return(ClickNode(child)); } return(false); }
private void InnerBeginFill(object state) { try { using (reader = new ForwardExcelReader(base.DataProvider.DataSourceFile)) { reader.Open(); sheet1 = reader.Activate(1) as ForwardReadWorksheet; sheet2 = reader.Activate(2) as ForwardReadWorksheet; Hashtable table = ReadColumnSheet(); tableList = ReadRowSheet(table); for (CurrentRowIndex = 0; CurrentRowIndex < tableList.Count; CurrentRowIndex++) { _asyncObject.Reset(); bool isBusy = true; while (isBusy) { System.Threading.Thread.Sleep(100); base.Browser.Invoke((Action)(() => { isBusy = base.Browser.IsBusy; })); } base.Browser.Invoke((Action)(() => { base.Browser.Navigate(base.StartPageUri); })); base.BeginFill(); _asyncObject.Wait(); } base.OnFinished(EventArgs.Empty); WebFillManager.ShowMessageBox("填报已完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { if (ex is System.Threading.ThreadAbortException) { return; } else { WebFillManager.ShowMessageBox(ex.Message, "错误", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } }
/// <summary> /// 挂起当前线程,直到Resume方法被调用。 /// </summary> public void Suspend() { _asyncObject.Wait(); FillState = FillState.Suspended; _asyncObject.Suspend(); }