Method TryEnterUpgradedWriteGuard
TryEnterUpgradedWriteGuard(int)
Tries to upgrade to write access within the given timeout, returning a write guard whose IsEntered property indicates whether write mode was entered. Disposing the returned guard exits write mode (returning this thread to upgradeable read mode), or is a no-op if write mode was not entered.
Declaration
public WriteGuard TryEnterUpgradedWriteGuard(int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| int | millisecondsTimeout | The number of milliseconds to wait, or
Infinite ( |
Returns
| Type | Description |
|---|---|
| WriteGuard |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The guard has been disposed. |
| InvalidOperationException | The guard did not enter the lock, has been downgraded to a read lock, is already upgraded, or the operation was attempted on a different thread than the one that entered the lock. |
TryEnterUpgradedWriteGuard(TimeSpan)
Tries to upgrade to write access within the given timeout, returning a write guard whose IsEntered property indicates whether write mode was entered. Disposing the returned guard exits write mode (returning this thread to upgradeable read mode), or is a no-op if write mode was not entered.
Declaration
public WriteGuard TryEnterUpgradedWriteGuard(TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeout | The amount of time to wait, or InfiniteTimeSpan to wait indefinitely. |
Returns
| Type | Description |
|---|---|
| WriteGuard |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The guard has been disposed. |
| InvalidOperationException | The guard did not enter the lock, has been downgraded to a read lock, is already upgraded, or the operation was attempted on a different thread than the one that entered the lock. |