VerifyAccess() public method

Verifies that the current thread is the documents owner thread. Throws an InvalidOperationException if the wrong thread accesses the TextDocument.

The TextDocument class is not thread-safe. A document instance expects to have a single owner thread and will throw an InvalidOperationException when accessed from another thread. It is possible to change the owner thread using the SetOwnerThread method.

public VerifyAccess ( ) : void
return void
コード例 #1
0
 DocumentLine IList <DocumentLine> .this[int index] {
     get {
         document.VerifyAccess();
         return(GetByNumber(1 + index));
     }
     set {
         throw new NotSupportedException();
     }
 }
コード例 #2
0
ファイル: FoldingManager.cs プロジェクト: arkanoid1/Yanitta
 /// <summary>
 /// Creates a new FoldingManager instance.
 /// </summary>
 public FoldingManager(TextDocument document)
 {
     if (document == null)
         throw new ArgumentNullException(nameof(document));
     this.document = document;
     foldings = new TextSegmentCollection<FoldingSection>();
     document.VerifyAccess();
     TextDocumentWeakEventManager.Changed.AddListener(document, this);
 }
コード例 #3
0
		/// <summary>
		/// Creates a new TextSegmentCollection that updates the offsets automatically.
		/// </summary>
		/// <param name="textDocument">The document to which the text segments
		/// that will be added to the tree belong. When the document changes, the
		/// position of the text segments will be updated accordingly.</param>
		public TextSegmentCollection(TextDocument textDocument)
		{
			if (textDocument == null)
				throw new ArgumentNullException("textDocument");
			
			textDocument.VerifyAccess();
			isConnectedToDocument = true;
			TextDocumentWeakEventManager.Changed.AddListener(textDocument, this);
		}
コード例 #4
0
        public AvalonEditTextDocument(ICSharpCode.AvalonEdit.Document.TextDocument avalonEditTextDocument, Encoding encodingForAlphanumericLiterals, ColumnsLayout columnsLayout)
        {
            // Document source name and text format
            Source = new TextSourceInfo(_avalonEditTextDocument.FileName, encodingForAlphanumericLiterals, columnsLayout);

            _avalonEditTextDocument = avalonEditTextDocument;
            // Listen to all line changes in the editor
            _avalonEditTextDocument.VerifyAccess();
            _weakLineTracker = WeakLineTracker.Register(_avalonEditTextDocument, this);
        }
コード例 #5
0
        public AvalonEditTextDocument(ICSharpCode.AvalonEdit.Document.TextDocument avalonEditTextDocument, Encoding encodingForAlphanumericLiterals, ColumnsLayout columnsLayout)
        {
            // Document source name and text format
            Source = new TextSourceInfo(_avalonEditTextDocument.FileName, encodingForAlphanumericLiterals, columnsLayout);

            _avalonEditTextDocument = avalonEditTextDocument;
            // Listen to all line changes in the editor
            _avalonEditTextDocument.VerifyAccess();
            _weakLineTracker = WeakLineTracker.Register(_avalonEditTextDocument, this);
        }
コード例 #6
0
		/// <summary>
		/// Creates a new FoldingManager instance.
		/// </summary>
		public FoldingManager(TextView textView, TextDocument document)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			if (document == null)
				throw new ArgumentNullException("document");
			this.textView = textView;
			this.document = document;
			this.foldings = new TextSegmentCollection<FoldingSection>();
			document.VerifyAccess();
			TextDocumentWeakEventManager.Changed.AddListener(document, this);
		}