|
13 | 13 | <BaseTypeName>System.Object</BaseTypeName>
|
14 | 14 | </Base>
|
15 | 15 | <Interfaces />
|
16 |
| - <Attributes> |
17 |
| - <Attribute> |
18 |
| - <AttributeName Language="C#">[System.Runtime.Versioning.RequiresPreviewFeatures]</AttributeName> |
19 |
| - <AttributeName Language="F#">[<System.Runtime.Versioning.RequiresPreviewFeatures>]</AttributeName> |
20 |
| - </Attribute> |
21 |
| - </Attributes> |
| 16 | + <Attributes /> |
22 | 17 | <Docs>
|
23 |
| - <summary>To be added.</summary> |
24 |
| - <remarks>To be added.</remarks> |
| 18 | + <summary>Provides a mechanism for achieving mutual exclusion in regions of code between different threads.</summary> |
| 19 | + <remarks> |
| 20 | + <format type="text/markdown"><. |
| 35 | +
|
| 36 | +<xref:System.Threading.Thread.Interrupt%2A> can interrupt threads that are waiting to enter a lock. On Windows STA threads, waits for locks allow message pumping that may run other code on the same thread during a wait. Some features of the waits may be overridden by a custom <xref:System.Threading.SynchronizationContext>. |
| 37 | +
|
| 38 | +> [!NOTE] |
| 39 | +> A thread that enters a lock, including multiple times such as recursively, must exit the lock the same number of times to fully exit the lock and allow other threads to enter the lock. If a thread exits while holding a `Lock`, the behavior of the `Lock` becomes undefined. |
| 40 | +
|
| 41 | +> [!CAUTION] |
| 42 | +> If on a code path a thread may enter multiple locks before exiting them, ensure that all code paths that may enter any two of those locks on the same thread enter them in the same order. Otherwise, it could lead to deadlocks. For example, consider that on one code path thread `T1` enters lock `L1` then lock `L2` before exiting both, and on another code path thread `T2` enters both locks in the inverse order. In that scenario, it would be possible for the following order of events to occur: `T1` enters `L1`, `T2` enters `L2`, `T1` tries to enter `L2` and waits, `T2` tries to enter `L1` and waits - there's a deadlock between `T1` and `T2` that cannot be resolved, and any other threads that try to enter either lock in the future will also hang. |
| 43 | +
|
| 44 | + ]]></format> |
| 45 | + </remarks> |
25 | 46 | </Docs>
|
26 | 47 | <Members>
|
27 | 48 | <Member MemberName=".ctor">
|
|
37 | 58 | </AssemblyInfo>
|
38 | 59 | <Parameters />
|
39 | 60 | <Docs>
|
40 |
| - <summary>To be added.</summary> |
41 |
| - <remarks>To be added.</remarks> |
| 61 | + <summary>Initializes a new instance of the <see cref="T:System.Threading.Lock" /> class.</summary> |
42 | 62 | </Docs>
|
43 | 63 | </Member>
|
44 | 64 | <Member MemberName="Enter">
|
|
58 | 78 | </ReturnValue>
|
59 | 79 | <Parameters />
|
60 | 80 | <Docs>
|
61 |
| - <summary>To be added.</summary> |
62 |
| - <remarks>To be added.</remarks> |
| 81 | + <summary>Enters the lock, waiting if necessary until the lock can be entered.</summary> |
| 82 | + <remarks> |
| 83 | + <format type="text/markdown"><![CDATA[ |
| 84 | +
|
| 85 | +## Remarks |
| 86 | +
|
| 87 | +When the method returns, the current thread would be the only thread that holds the lock. If the lock cannot be entered immediately, the method waits until the lock can be entered. If the lock is already held by the current thread, the lock is entered again. The current thread should exit the lock as many times as it had entered the lock to fully exit the lock and allow other threads to enter the lock. |
| 88 | +
|
| 89 | +For more information, see the Remarks for <xref:System.Threading.Lock>. |
| 90 | +
|
| 91 | + ]]></format> |
| 92 | + </remarks> |
| 93 | + <exception cref="System.Threading.LockRecursionException">The lock has reached the limit of repeated enters by the current thread. The limit is implementation-defined and is intended to be high enough that it would not be reached in normal situations.</exception> |
63 | 94 | </Docs>
|
64 | 95 | </Member>
|
65 | 96 | <Member MemberName="EnterScope">
|
|
79 | 110 | </ReturnValue>
|
80 | 111 | <Parameters />
|
81 | 112 | <Docs>
|
82 |
| - <summary>To be added.</summary> |
83 |
| - <returns>To be added.</returns> |
84 |
| - <remarks>To be added.</remarks> |
| 113 | + <summary>Enters the lock, waiting if necessary until the lock can be entered.</summary> |
| 114 | + <returns>A <see cref="T:System.Threading.Lock.Scope"/> that may be disposed to exit the lock.</returns> |
| 115 | + <remarks> |
| 116 | + <format type="text/markdown"><![CDATA[ |
| 117 | +
|
| 118 | +## Remarks |
| 119 | +
|
| 120 | +If the lock cannot be entered immediately, the method waits until the lock can be entered. If the lock is already held by the current thread, the lock is entered again. The current thread should dispose the returned <xref:System.Threading.Lock.Scope> to exit the lock as many times as it had entered the lock to fully exit the lock and allow other threads to enter the lock. |
| 121 | +
|
| 122 | +This method is intended to be used along with a language construct that would automatically dispose the <xref:System.Threading.Lock.Scope>, such as with the C# `using` keyword. |
| 123 | +
|
| 124 | +For more information, see the Remarks for <xref:System.Threading.Lock>. |
| 125 | +
|
| 126 | + ]]></format> |
| 127 | + </remarks> |
| 128 | + <exception cref="System.Threading.LockRecursionException">The lock has reached the limit of repeated enters by the current thread. The limit is implementation-defined and is intended to be high enough that it would not be reached in normal situations.</exception> |
85 | 129 | </Docs>
|
86 | 130 | </Member>
|
87 | 131 | <Member MemberName="Exit">
|
|
101 | 145 | </ReturnValue>
|
102 | 146 | <Parameters />
|
103 | 147 | <Docs>
|
104 |
| - <summary>To be added.</summary> |
105 |
| - <remarks>To be added.</remarks> |
| 148 | + <summary>Exits the lock.</summary> |
| 149 | + <remarks> |
| 150 | + <format type="text/markdown"><![CDATA[ |
| 151 | +
|
| 152 | +## Remarks |
| 153 | +
|
| 154 | +If the current thread holds the lock multiple times, such as recursively, the lock is exited only once. The current thread should ensure that each enter is matched with an exit. |
| 155 | +
|
| 156 | +For more information, see the Remarks for <xref:System.Threading.Lock>. |
| 157 | +
|
| 158 | + ]]></format> |
| 159 | + </remarks> |
| 160 | + <exception cref="System.Threading.SynchronizationLockException">The current thread does not hold the lock.</exception> |
106 | 161 | </Docs>
|
107 | 162 | </Member>
|
108 | 163 | <Member MemberName="IsHeldByCurrentThread">
|
|
121 | 176 | <ReturnType>System.Boolean</ReturnType>
|
122 | 177 | </ReturnValue>
|
123 | 178 | <Docs>
|
124 |
| - <summary>To be added.</summary> |
125 |
| - <value>To be added.</value> |
126 |
| - <remarks>To be added.</remarks> |
| 179 | + <summary>Indicates whether the lock is held by the current thread.</summary> |
| 180 | + <value><see langword="true" /> if the current thread holds the lock; otherwise, <see langword="false" />.</value> |
127 | 181 | </Docs>
|
128 | 182 | </Member>
|
129 | 183 | <Member MemberName="TryEnter">
|
|
143 | 197 | </ReturnValue>
|
144 | 198 | <Parameters />
|
145 | 199 | <Docs>
|
146 |
| - <summary>To be added.</summary> |
147 |
| - <returns>To be added.</returns> |
148 |
| - <remarks>To be added.</remarks> |
| 200 | + <summary>Tries to enter the lock without waiting.</summary> |
| 201 | + <returns><see langword="true" /> if the lock was entered by the current thread; otherwise, <see langword="false" />.</returns> |
| 202 | + <remarks> |
| 203 | + <format type="text/markdown"><![CDATA[ |
| 204 | +
|
| 205 | +## Remarks |
| 206 | +
|
| 207 | +When the method returns `true`, the current thread would be the only thread that holds the lock. If the lock cannot be entered immediately, the method returns `false` without waiting for the lock. If the lock is already held by the current thread, the lock is entered again. The current thread should exit the lock as many times as it had entered the lock to fully exit the lock and allow other threads to enter the lock. |
| 208 | +
|
| 209 | +For more information, see the Remarks for <xref:System.Threading.Lock>. |
| 210 | +
|
| 211 | + ]]></format> |
| 212 | + </remarks> |
| 213 | + <exception cref="System.Threading.LockRecursionException">The lock has reached the limit of repeated enters by the current thread. The limit is implementation-defined and is intended to be high enough that it would not be reached in normal situations.</exception> |
149 | 214 | </Docs>
|
150 | 215 | </Member>
|
151 | 216 | <Member MemberName="TryEnter">
|
|
167 | 232 | <Parameter Name="millisecondsTimeout" Type="System.Int32" />
|
168 | 233 | </Parameters>
|
169 | 234 | <Docs>
|
170 |
| - <param name="millisecondsTimeout">To be added.</param> |
171 |
| - <summary>To be added.</summary> |
172 |
| - <returns>To be added.</returns> |
173 |
| - <remarks>To be added.</remarks> |
| 235 | + <param name="millisecondsTimeout">The number of milliseconds to wait until the lock can be entered. The value may be <see cref="F:System.Threading.Timeout.Infinite" /> (<code>-1</code>) to wait indefinitely, or <code>0</code> to not wait.</param> |
| 236 | + <summary>Tries to enter the lock, waiting if necessary for the specified number of milliseconds until the lock can be entered.</summary> |
| 237 | + <returns><see langword="true" /> if the lock was entered by the current thread; otherwise, <see langword="false" />.</returns> |
| 238 | + <remarks> |
| 239 | + <format type="text/markdown"><![CDATA[ |
| 240 | +
|
| 241 | +## Remarks |
| 242 | +
|
| 243 | +When the method returns `true`, the current thread would be the only thread that holds the lock. If the lock cannot be entered immediately, the method waits until the lock can be entered or until the timeout specified by the `millisecondsTimeout` parameter expires. If the timeout expires before entering the lock, the method returns `false`. If the lock is already held by the current thread, the lock is entered again. The current thread should exit the lock as many times as it had entered the lock to fully exit the lock and allow other threads to enter the lock. |
| 244 | +
|
| 245 | +For more information, see the Remarks for <xref:System.Threading.Lock>. |
| 246 | +
|
| 247 | + ]]></format> |
| 248 | + </remarks> |
| 249 | + <exception cref="System.Threading.ArgumentOutOfRangeException"><paramref name="millisecondsTimeout"/> is less than <code>-1</code>.</exception> |
| 250 | + <exception cref="System.Threading.LockRecursionException">The lock has reached the limit of repeated enters by the current thread. The limit is implementation-defined and is intended to be high enough that it would not be reached in normal situations.</exception> |
174 | 251 | </Docs>
|
175 | 252 | </Member>
|
176 | 253 | <Member MemberName="TryEnter">
|
|
192 | 269 | <Parameter Name="timeout" Type="System.TimeSpan" />
|
193 | 270 | </Parameters>
|
194 | 271 | <Docs>
|
195 |
| - <param name="timeout">To be added.</param> |
196 |
| - <summary>To be added.</summary> |
197 |
| - <returns>To be added.</returns> |
198 |
| - <remarks>To be added.</remarks> |
| 272 | + <param name="timeout">A <see cref="T:System.TimeSpan" /> that represents the number of milliseconds to wait until the lock can be entered. A value that represents <see cref="F:System.Threading.Timeout.Infinite" /> (<code>-1</code>) milliseconds specifies to wait indefinitely, and a value that represents <code>0</code> milliseconds specifies to not wait.</param> |
| 273 | + <summary>Tries to enter the lock, waiting if necessary until the lock can be entered or until the specified timeout expires.</summary> |
| 274 | + <returns><see langword="true" /> if the lock was entered by the current thread; otherwise, <see langword="false" />.</returns> |
| 275 | + <remarks> |
| 276 | + <format type="text/markdown"><![CDATA[ |
| 277 | +
|
| 278 | +## Remarks |
| 279 | +
|
| 280 | +When the method returns `true`, the current thread would be the only thread that holds the lock. If the lock cannot be entered immediately, the method waits until the lock can be entered or until the specified `timeout` expires. If the timeout expires before entering the lock, the method returns `false`. If the lock is already held by the current thread, the lock is entered again. The current thread should exit the lock as many times as it had entered the lock to fully exit the lock and allow other threads to enter the lock. |
| 281 | +
|
| 282 | +For more information, see the Remarks for <xref:System.Threading.Lock>. |
| 283 | +
|
| 284 | + ]]></format> |
| 285 | + </remarks> |
| 286 | + <exception cref="System.Threading.ArgumentOutOfRangeException"><paramref name="timeout"/>, after its conversion to an integer millisecond value, represents a value that is less than <code>-1</code> milliseconds or greater than <see cref="int.MaxValue"/> milliseconds.</exception> |
| 287 | + <exception cref="System.Threading.LockRecursionException">The lock has reached the limit of repeated enters by the current thread. The limit is implementation-defined and is intended to be high enough that it would not be reached in normal situations.</exception> |
199 | 288 | </Docs>
|
200 | 289 | </Member>
|
201 | 290 | </Members>
|
|
0 commit comments