Struct LockToken
Propagates notification that some data has been locked and can no longer be modified.
Implements
Inherited Members
Namespace: EmbedIO.Utilities
Syntax
public struct LockToken : IEquatable<LockToken>
Remarks
A LockToken is usually created through the Token property of an instance of LockTokenSource.
Once locked, a token will never transition to a non-locked state.
The special token named None, equal to
langword_csharp_default(LockToken), is the only token
that can never be locked.
All members of this langword_csharp_struct are thread-safe and may be used concurrently from multiple threads.
Properties
IsLocked
Gets whether this token is locked.
Declaration
public bool IsLocked { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
None
Gets an empty LockToken, i.e. a token that has no source and will never be locked.
The value of this property is equal to
langword_csharp_default(LockToken).
Declaration
public static LockToken None { get; }
Property Value
| Type | Description |
|---|---|
| LockToken |
Methods
Equals(LockToken)
Determines whether the current LockToken instance is equal to the specified token.
Declaration
public bool Equals(LockToken other)
Parameters
| Type | Name | Description |
|---|---|---|
| LockToken | other | The other LockToken to compare with this instance. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the instances are equal; otherwise, false. See the Remarks section for more information. |
Remarks
Two lock tokens are equal if any one of the following conditions is true:
- they are associated with the same LockTokenSource;
- the value of both tokens is None.
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj |
Returns
| Type | Description |
|---|---|
| Boolean |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 |
Overrides
ThrowIfLocked()
Throws a LockedException if this token is locked.
Declaration
public void ThrowIfLocked()
Exceptions
| Type | Condition |
|---|---|
| LockedException | The token is locked. |
Operators
Equality(LockToken, LockToken)
Determines whether two LockToken instances are equal.
Declaration
public static bool operator ==(LockToken a, LockToken b)
Parameters
| Type | Name | Description |
|---|---|---|
| LockToken | a | The first instance. |
| LockToken | b | The second instance. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the instances are equal; otherwise, false. For the definition of equality, see the Equals(LockToken) method. |
See Also
Inequality(LockToken, LockToken)
Determines whether two LockToken instances are not equal.
Declaration
public static bool operator !=(LockToken a, LockToken b)
Parameters
| Type | Name | Description |
|---|---|---|
| LockToken | a | The first instance. |
| LockToken | b | The second instance. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the instances are not equal; otherwise, false. For the definition of equality, see the Equals(LockToken) method. |