private void btnAsync_Click(object sender, System.EventArgs e) { ClearLog(); // As we will now be working with several objects at the same time, // we declare arrays of XmlDocument, Delegate and the IAsyncResult XmlDocument[] Documents = new XmlDocument[mUrlList.Count]; DocumentLoad[] Delegates = new DocumentLoad[mUrlList.Count]; // VS.NET does not support arrays of interface type with // Intellisense, but this code is valid C# and compiles fine IAsyncResult[] Tickets = new IAsyncResult[mUrlList.Count]; for (int i = 0; i < mUrlList.Count; i++) { Documents[i] = new XmlDocument(); Delegates[i] = new DocumentLoad(Documents[i].Load); // The next line starts the loading of the XmlDocument on a // different thread. We don't have to wait for its completion now. // The two null parameters at the end are for use with callback functions. Tickets[i] = Delegates[i].BeginInvoke((string)mUrlList[i], null, null); AppendLog("Started loading document from " + mUrlList[i]); } for (int i = 0; i < mUrlList.Count; i++) { // Force to wait here until the call is completed. We // could have called BeginInvoke multiple times on the // same delegate instance, so we need the ticket (of // type IAsyncResult) to specify which call we mean exactly. Delegates[i].EndInvoke(Tickets[i]); AppendLog("Loaded document from " + mUrlList[i]); } }
public void Process() { string fullFileName = txtPath.Text; string table = string.Format("'{0}'", txtNotice.Text.Replace("\r\n", "','")); CreateWord(fullFileName); WriteControl(string.Format("创建{0}成功!", fullFileName)); System.Data.DataTable userDataTable = OracleDocument.GetAllUserTable(); if (!cbIsAllTable.Checked) { userDataTable.DefaultView.RowFilter = string.Format(" table_name in({0})", table); userDataTable = userDataTable.DefaultView.ToTable(); } WordHelper wordHelper = new WordHelper(); wordHelper.OpenDocument(fullFileName); WriteControl(string.Format("{1}开始生成表,共{0}个………………", userDataTable.Rows.Count, DateTime.Now.ToString("HH:mm:ss"))); for (int i = 1; i <= userDataTable.Rows.Count; i++) { Table userTable = DocumentLoad.GetTableEntityByDataRow(userDataTable.Rows[i - 1]); WriteControl(string.Format("{2} 第{0}个,{1}表………………", i, userTable.TableName, DateTime.Now.ToString("HH:mm:ss"))); wordHelper.SetFont(14f); wordHelper.InsertText(string.Format("{0}、{1}({2})", i, userTable.TableName, userTable.Comments)); CreateWordTables(userTable, wordHelper); WriteControl(string.Format("{1} {0}表生成成功!", userTable.TableName, DateTime.Now.ToString("HH:mm:ss"))); if (IsStop) { break; } } wordHelper.SaveDocument(fullFileName); MessageBox.Show(string.Format("文档生成成功!", fullFileName)); }
private IEnumerable <ITextView> GetDocumentTextViews(DocumentLoad documentLoad) { var list = new List <ITextView>(); foreach (var textBuffer in GetDocumentTextBuffers(documentLoad)) { list.AddRange(GetTextViews(textBuffer)); } return(list); }
private IEnumerable<ITextBuffer> GetDocumentTextBuffers(DocumentLoad documentLoad) { var list = new List<ITextBuffer>(); foreach (var docCookie in _runningDocumentTable.GetRunningDocumentCookies()) { if (documentLoad == DocumentLoad.RespectLazy && _sharedService.IsLazyLoaded(docCookie)) { continue; } ITextBuffer buffer; if (_vsAdapter.GetTextBufferForDocCookie(docCookie).TryGetValue(out buffer)) { list.Add(buffer); } } return list; }
private IEnumerable <ITextBuffer> GetDocumentTextBuffers(DocumentLoad documentLoad) { var list = new List <ITextBuffer>(); foreach (var docCookie in _runningDocumentTable.GetRunningDocumentCookies()) { if (documentLoad == DocumentLoad.RespectLazy && _sharedService.IsLazyLoaded(docCookie)) { continue; } if (_vsAdapter.GetTextBufferForDocCookie(docCookie).TryGetValue(out ITextBuffer buffer)) { list.Add(buffer); } } return(list); }
private void btnCallback_Click(object sender, System.EventArgs e) { ClearLog(); XmlDocument[] Documents = new XmlDocument[mUrlList.Count]; for (int i = 0; i < mUrlList.Count; i++) { Documents[i] = new XmlDocument(); DocumentLoad TheDelegate = new DocumentLoad(Documents[i].Load); AsyncCallback CallbackDelegate = new AsyncCallback(this.ReadyLoading); // We start the loading of the XMLDocument, passing it a delegate // for calling the ReadyLoading method when it is ready. A reference // to the current XmlDocument is also passed in. This will be passed // to the callback method as the AsyncState property of the IAsyncResult. TheDelegate.BeginInvoke((string)mUrlList[i], CallbackDelegate, Documents[i]); AppendLog("Started loading document from " + mUrlList[i]); } }
private IEnumerable <ITextBuffer> GetDocumentTextBuffers(DocumentLoad documentLoad) { var list = new List <ITextBuffer>(); foreach (var docCookie in _runningDocumentTable.GetRunningDocumentCookies()) { if (documentLoad == DocumentLoad.RespectLazy && isLazyLoaded(docCookie)) { continue; } if (_vsAdapter.GetTextBufferForDocCookie(docCookie).TryGetValue(out ITextBuffer buffer)) { list.Add(buffer); } } return(list); bool isLazyLoaded(uint documentCookie) { try { if (_runningDocumentTable4 is null) { _runningDocumentTable4 = _serviceProvider.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable4>(); } var flags = (_VSRDTFLAGS4)_runningDocumentTable4.GetDocumentFlags(documentCookie); return(0 != (flags & _VSRDTFLAGS4.RDT_PendingInitialization)); } catch (Exception) { return(false); } } }
IEnumerable <ITextView> ITextManager.GetDocumentTextViews(DocumentLoad documentLoad) { return(GetDocumentTextViews(documentLoad)); }
IEnumerable <ITextBuffer> ITextManager.GetDocumentTextBuffers(DocumentLoad documentLoad) { return(GetDocumentTextBuffers(documentLoad)); }
protected virtual void OnDocumentLoad(object sender, DocumentLoadEventArgs e) { DocumentLoad?.Invoke(sender, e); }
private IEnumerable<ITextView> GetDocumentTextViews(DocumentLoad documentLoad) { var list = new List<ITextView>(); foreach (var textBuffer in GetDocumentTextBuffers(documentLoad)) { list.AddRange(GetTextViews(textBuffer)); } return list; }
IEnumerable<ITextView> ITextManager.GetDocumentTextViews(DocumentLoad documentLoad) { return GetDocumentTextViews(documentLoad); }
IEnumerable<ITextBuffer> ITextManager.GetDocumentTextBuffers(DocumentLoad documentLoad) { return GetDocumentTextBuffers(documentLoad); }