Skip to content

Commit 768479b

Browse files
committed
Document LINQ to XML thread safety
Explain that concurrent reads are safe when no thread modifies the XObject, XDocument, or XElement instance. Fix dotnet/runtime#123068
1 parent ac69dc2 commit 768479b

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

xml/System.Xml.Linq/XDocument.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
## Remarks
5656
For details about the valid content of an <xref:System.Xml.Linq.XDocument>, see [Valid Content of XElement and XDocument Objects](/dotnet/standard/linq/valid-content-xelement-xdocument-objects).
5757
58+
## Thread safety
59+
60+
An <xref:System.Xml.Linq.XDocument> instance is safe for concurrent read operations as long as no thread modifies it. If the instance is modified, you must synchronize all access to it.
61+
5862
5963
6064
## Examples

xml/System.Xml.Linq/XElement.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
8686
Some <xref:System.Xml.Linq.XElement> methods can be used from XAML. For more information, see [LINQ to XML Dynamic Properties](/dotnet/desktop/wpf/data/linq-to-xml-dynamic-properties).
8787
88+
## Thread safety
89+
90+
An <xref:System.Xml.Linq.XElement> instance is safe for concurrent read operations as long as no thread modifies it. If the instance is modified, you must synchronize all access to it.
91+
8892
8993
9094
## Examples

xml/System.Xml.Linq/XObject.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
6262
Note that annotations are not part of the XML infoset; they are not serialized or deserialized.
6363
64+
## Thread safety
65+
66+
An <xref:System.Xml.Linq.XObject> instance, including an instance of a derived type, is safe for concurrent read operations as long as no thread modifies it. If the instance is modified, you must synchronize all access to it.
67+
6468
]]></format>
6569
</remarks>
6670
<related type="Article" href="/dotnet/standard/linq/linq-xml-overview">LINQ to XML overview</related>

0 commit comments

Comments
 (0)