Skip to content

Commit dda45ad

Browse files
committed
Clarify CookieContainer thread-safety
1 parent 4855510 commit dda45ad

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

xml/System.Net/CookieContainer.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@
7979
8080
]]></format>
8181
</remarks>
82+
<threadsafe>
83+
<format type="text/markdown"><![CDATA[
84+
85+
## Thread Safety
86+
87+
The methods for adding and retrieving <xref:System.Net.Cookie> instances to/from a <xref:System.Net.CookieContainer> are thread-safe and may be used concurrently from multiple threads.
88+
89+
> [!NOTE]
90+
> Regardless of thread-safety, unanticipated sharing of <xref:System.Net.CookieContainer> may lead to issues when working with <xref:System.Net.Http.HttpClient> and <xref:System.Net.Http.HttpClientHandler> or <xref:System.Net.Http.SocketsHttpHandler>.
91+
> One such problem is isolation: parts of the application that not intended to share cookies may inadvertently do so.
92+
> It is not recommended to use cookies together with <xref:System.Net.Http.IHttpClientFactory>.
93+
94+
]]></format>
95+
</threadsafe>
8296
<altmember cref="T:System.Net.Cookie" />
8397
<altmember cref="T:System.Net.CookieCollection" />
8498
<altmember cref="T:System.Net.CookieContainer" />

0 commit comments

Comments
 (0)