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
Exemplo n.º 1
0
 DocumentLine IList <DocumentLine> .this[int index]
 {
     get
     {
         document.VerifyAccess();
         return(GetByNumber(1 + index));
     }
     set
     {
         throw new NotSupportedException();
     }
 }
        /// <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;
            WeakSubscriptionManager.Subscribe(textDocument, nameof(textDocument.Changed), this);
        }