Skip to content

Commit b793c49

Browse files
authored
Merge pull request #1466 from microsoft/copilot/fix-1128
Document InvalidOperationException for AsyncReaderWriterLock acquisition methods
1 parent b3c2d21 commit b793c49

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Microsoft.VisualStudio.Threading/AsyncReaderWriterLock.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ protected virtual bool IsUnsupportedSynchronizationContext
414414
/// a canceled token will cause the code that is waiting for the lock to resume with an <see cref="OperationCanceledException"/>.
415415
/// </param>
416416
/// <returns>An awaitable object whose result is the lock releaser.</returns>
417+
/// <exception cref="InvalidOperationException">Thrown when <see cref="Complete"/> has been called and this is a new top-level lock request.</exception>
417418
public Awaitable ReadLockAsync(CancellationToken cancellationToken = default(CancellationToken))
418419
{
419420
return new Awaitable(this, LockKind.Read, LockFlags.None, cancellationToken);
@@ -428,13 +429,14 @@ protected virtual bool IsUnsupportedSynchronizationContext
428429
/// a canceled token will cause the code that is waiting for the lock to resume with an <see cref="OperationCanceledException"/>.
429430
/// </param>
430431
/// <returns>An awaitable object whose result is the lock releaser.</returns>
432+
/// <exception cref="InvalidOperationException">Thrown when <see cref="Complete"/> has been called and this is a new top-level lock request.</exception>
431433
public Awaitable UpgradeableReadLockAsync(CancellationToken cancellationToken = default(CancellationToken))
432434
{
433435
return new Awaitable(this, LockKind.UpgradeableRead, LockFlags.None, cancellationToken);
434436
}
435437

436438
/// <summary>
437-
/// Obtains a read lock, asynchronously awaiting for the lock if it is not immediately available.
439+
/// Obtains an upgradeable read lock, asynchronously awaiting for the lock if it is not immediately available.
438440
/// </summary>
439441
/// <param name="options">Modifications to normal lock behavior.</param>
440442
/// <param name="cancellationToken">
@@ -443,6 +445,7 @@ protected virtual bool IsUnsupportedSynchronizationContext
443445
/// a canceled token will cause the code that is waiting for the lock to resume with an <see cref="OperationCanceledException"/>.
444446
/// </param>
445447
/// <returns>An awaitable object whose result is the lock releaser.</returns>
448+
/// <exception cref="InvalidOperationException">Thrown when <see cref="Complete"/> has been called and this is a new top-level lock request.</exception>
446449
public Awaitable UpgradeableReadLockAsync(LockFlags options, CancellationToken cancellationToken = default(CancellationToken))
447450
{
448451
return new Awaitable(this, LockKind.UpgradeableRead, options, cancellationToken);
@@ -457,6 +460,7 @@ protected virtual bool IsUnsupportedSynchronizationContext
457460
/// a canceled token will cause the code that is waiting for the lock to resume with an <see cref="OperationCanceledException"/>.
458461
/// </param>
459462
/// <returns>An awaitable object whose result is the lock releaser.</returns>
463+
/// <exception cref="InvalidOperationException">Thrown when <see cref="Complete"/> has been called and this is a new top-level lock request.</exception>
460464
public Awaitable WriteLockAsync(CancellationToken cancellationToken = default(CancellationToken))
461465
{
462466
return new Awaitable(this, LockKind.Write, LockFlags.None, cancellationToken);
@@ -472,6 +476,7 @@ protected virtual bool IsUnsupportedSynchronizationContext
472476
/// a canceled token will cause the code that is waiting for the lock to resume with an <see cref="OperationCanceledException"/>.
473477
/// </param>
474478
/// <returns>An awaitable object whose result is the lock releaser.</returns>
479+
/// <exception cref="InvalidOperationException">Thrown when <see cref="Complete"/> has been called and this is a new top-level lock request.</exception>
475480
public Awaitable WriteLockAsync(LockFlags options, CancellationToken cancellationToken = default(CancellationToken))
476481
{
477482
return new Awaitable(this, LockKind.Write, options, cancellationToken);

0 commit comments

Comments
 (0)